Enviar pesquisa
Carregar
10g sql e book
•
0 gostou
•
2,865 visualizações
M
Mansoor Abd Algadir
Seguir
ORACLE 10 G SQL
Leia menos
Leia mais
Educação
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 425
Baixar agora
Baixar para ler offline
Recomendados
Database Performance Management in Cloud
Database Performance Management in Cloud
Dr. Amarjeet Singh
DATABASE ADMINSTRATION
DATABASE ADMINSTRATION
Nusrat Gulbarga
notes
notes
myonlineworld
Handy annotations-within-oracle-10g
Handy annotations-within-oracle-10g
VESIT/University of Mumbai
1 introduction
1 introduction
Ngeam Soly
Rdbms Practical file diploma
Rdbms Practical file diploma
mustkeem khan
Oracle Optimized Datacenter - Storage
Oracle Optimized Datacenter - Storage
Walter Moriconi
Satwinder SQL.SSK_Brd_2015
Satwinder SQL.SSK_Brd_2015
Satwinder Khural
Recomendados
Database Performance Management in Cloud
Database Performance Management in Cloud
Dr. Amarjeet Singh
DATABASE ADMINSTRATION
DATABASE ADMINSTRATION
Nusrat Gulbarga
notes
notes
myonlineworld
Handy annotations-within-oracle-10g
Handy annotations-within-oracle-10g
VESIT/University of Mumbai
1 introduction
1 introduction
Ngeam Soly
Rdbms Practical file diploma
Rdbms Practical file diploma
mustkeem khan
Oracle Optimized Datacenter - Storage
Oracle Optimized Datacenter - Storage
Walter Moriconi
Satwinder SQL.SSK_Brd_2015
Satwinder SQL.SSK_Brd_2015
Satwinder Khural
Sybase job interview_preparation_guide
Sybase job interview_preparation_guide
NV Suresh Kumar
Ramesh_Oracle_DBA
Ramesh_Oracle_DBA
Ramesh Pillai
5-Ashutosh_resume
5-Ashutosh_resume
ashutosh satapathy
CV_Masood Ahmad_1110
CV_Masood Ahmad_1110
Masood Ahmad
Ado.net session10
Ado.net session10
Niit Care
Suresh Kumar
Suresh Kumar
Suresh Kumar
Rise of NewSQL
Rise of NewSQL
Sushant Choudhary
SQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10g
Leidy Alexandra
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
amitp26
Sql server difference faqs- 6
Sql server difference faqs- 6
Umar Ali
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
Mihir Gandhi
2ndlec.database
2ndlec.database
tayyabaraja
Ebook1
Ebook1
kaashiv1
NeilResume
NeilResume
Scott Neil
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2
Otto Paiz
Partitioning 11g-whitepaper-159443
Partitioning 11g-whitepaper-159443
Sandeep Chandra --seeking a new position
DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3
YOGESH SINGH
Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569
Naga Mallesh K
Database design challenges conflicting goals
Database design challenges conflicting goals
markilyn
DBArtisan XE6 Datasheet
DBArtisan XE6 Datasheet
Embarcadero Technologies
Machine Learning on the Microsoft Stack
Machine Learning on the Microsoft Stack
Lynn Langit
SSDT unleashed
SSDT unleashed
GomathiNayagam S
Mais conteúdo relacionado
Mais procurados
Sybase job interview_preparation_guide
Sybase job interview_preparation_guide
NV Suresh Kumar
Ramesh_Oracle_DBA
Ramesh_Oracle_DBA
Ramesh Pillai
5-Ashutosh_resume
5-Ashutosh_resume
ashutosh satapathy
CV_Masood Ahmad_1110
CV_Masood Ahmad_1110
Masood Ahmad
Ado.net session10
Ado.net session10
Niit Care
Suresh Kumar
Suresh Kumar
Suresh Kumar
Rise of NewSQL
Rise of NewSQL
Sushant Choudhary
SQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10g
Leidy Alexandra
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
amitp26
Sql server difference faqs- 6
Sql server difference faqs- 6
Umar Ali
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
Mihir Gandhi
2ndlec.database
2ndlec.database
tayyabaraja
Ebook1
Ebook1
kaashiv1
NeilResume
NeilResume
Scott Neil
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2
Otto Paiz
Partitioning 11g-whitepaper-159443
Partitioning 11g-whitepaper-159443
Sandeep Chandra --seeking a new position
DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3
YOGESH SINGH
Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569
Naga Mallesh K
Database design challenges conflicting goals
Database design challenges conflicting goals
markilyn
DBArtisan XE6 Datasheet
DBArtisan XE6 Datasheet
Embarcadero Technologies
Mais procurados
(20)
Sybase job interview_preparation_guide
Sybase job interview_preparation_guide
Ramesh_Oracle_DBA
Ramesh_Oracle_DBA
5-Ashutosh_resume
5-Ashutosh_resume
CV_Masood Ahmad_1110
CV_Masood Ahmad_1110
Ado.net session10
Ado.net session10
Suresh Kumar
Suresh Kumar
Rise of NewSQL
Rise of NewSQL
SQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10g
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
DBMS FOR STUDENTS MUST DOWNLOAD AND READ
Sql server difference faqs- 6
Sql server difference faqs- 6
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
Sigmod 2013 - On Brewing Fresh Espresso - LinkedIn's Distributed Data Serving...
2ndlec.database
2ndlec.database
Ebook1
Ebook1
NeilResume
NeilResume
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2
Partitioning 11g-whitepaper-159443
Partitioning 11g-whitepaper-159443
DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3
Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569
Database design challenges conflicting goals
Database design challenges conflicting goals
DBArtisan XE6 Datasheet
DBArtisan XE6 Datasheet
Destaque
Machine Learning on the Microsoft Stack
Machine Learning on the Microsoft Stack
Lynn Langit
SSDT unleashed
SSDT unleashed
GomathiNayagam S
SQL Reporting service presentation
SQL Reporting service presentation
Ahmed M. Rafik
Introduction of ssis
Introduction of ssis
deepakk073
Introduction To Msbi By Yasir
Introduction To Msbi By Yasir
guest7c8e5f
SQL Server Reporting Services (SSRS) 101
SQL Server Reporting Services (SSRS) 101
Sparkhound Inc.
SQL Server Reporting Services
SQL Server Reporting Services
Ahmed Elbaz
MSBI-SSRS PPT
MSBI-SSRS PPT
VIT-AP UNIVERSITY
SSIS Presentation
SSIS Presentation
BarbaraBederman
Introduction to MSBI
Introduction to MSBI
Edureka!
SQL Server Integration Services
SQL Server Integration Services
Robert MacLean
Getting Started with SQL Reporting Services Webinar
Getting Started with SQL Reporting Services Webinar
kaciefrey
Destaque
(12)
Machine Learning on the Microsoft Stack
Machine Learning on the Microsoft Stack
SSDT unleashed
SSDT unleashed
SQL Reporting service presentation
SQL Reporting service presentation
Introduction of ssis
Introduction of ssis
Introduction To Msbi By Yasir
Introduction To Msbi By Yasir
SQL Server Reporting Services (SSRS) 101
SQL Server Reporting Services (SSRS) 101
SQL Server Reporting Services
SQL Server Reporting Services
MSBI-SSRS PPT
MSBI-SSRS PPT
SSIS Presentation
SSIS Presentation
Introduction to MSBI
Introduction to MSBI
SQL Server Integration Services
SQL Server Integration Services
Getting Started with SQL Reporting Services Webinar
Getting Started with SQL Reporting Services Webinar
Semelhante a 10g sql e book
Sql interview question part 10
Sql interview question part 10
kaashiv1
Ebook10
Ebook10
kaashiv1
Database management system
Database management system
krishna partiwala
Ebook5
Ebook5
kaashiv1
Sql interview question part 5
Sql interview question part 5
kaashiv1
Report 1.0.docx
Report 1.0.docx
pinstechwork
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
ijscai
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
IJSCAI Journal
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
ijscai
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
IJSCAI Journal
Why Should you choose SQL Server 2019 ?
Why Should you choose SQL Server 2019 ?
SoftwareDeals
An Overview of Data Lake
An Overview of Data Lake
IRJET Journal
Data Base
Data Base
Susan Tullis
No sql database
No sql database
vishal gupta
58750024 datastage-student-guide
58750024 datastage-student-guide
Madhusudhanareddy Katta
Financial, Retail And Shopping Domains
Financial, Retail And Shopping Domains
Sonia Sanchez
10 Steps Optimize Share Point Performance
10 Steps Optimize Share Point Performance
Christopher Bunn
Migration to Oracle 12c Made Easy Using Replication Technology
Migration to Oracle 12c Made Easy Using Replication Technology
Donna Guazzaloca-Zehl
Report 2.0.docx
Report 2.0.docx
pinstechwork
Efficient and scalable multitenant placement approach for in memory database ...
Efficient and scalable multitenant placement approach for in memory database ...
CSITiaesprime
Semelhante a 10g sql e book
(20)
Sql interview question part 10
Sql interview question part 10
Ebook10
Ebook10
Database management system
Database management system
Ebook5
Ebook5
Sql interview question part 5
Sql interview question part 5
Report 1.0.docx
Report 1.0.docx
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A STUDY ON GRAPH STORAGE DATABASE OF NOSQL
A Study on Graph Storage Database of NOSQL
A Study on Graph Storage Database of NOSQL
Why Should you choose SQL Server 2019 ?
Why Should you choose SQL Server 2019 ?
An Overview of Data Lake
An Overview of Data Lake
Data Base
Data Base
No sql database
No sql database
58750024 datastage-student-guide
58750024 datastage-student-guide
Financial, Retail And Shopping Domains
Financial, Retail And Shopping Domains
10 Steps Optimize Share Point Performance
10 Steps Optimize Share Point Performance
Migration to Oracle 12c Made Easy Using Replication Technology
Migration to Oracle 12c Made Easy Using Replication Technology
Report 2.0.docx
Report 2.0.docx
Efficient and scalable multitenant placement approach for in memory database ...
Efficient and scalable multitenant placement approach for in memory database ...
Último
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
bronxfugly43
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
Poh-Sun Goh
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
TechSoup
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
Mebane Rash
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
MaryamAhmad92
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
Jisc
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
callscotland1987
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
pradhanghanshyam7136
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
Admir Softic
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
David Douglas School District
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
christianmathematics
Understanding Accommodations and Modifications
Understanding Accommodations and Modifications
MJDuyan
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
Amanpreet Kaur
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Celine George
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
TechSoup
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
christianmathematics
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
Último
(20)
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
Understanding Accommodations and Modifications
Understanding Accommodations and Modifications
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
10g sql e book
1.
Oracle 10g SQL
This book belongs to Name : ______________________________________ Batch : ______________________________________ SQL Star International Ltd. SQL Star House, No. 8-2-293/174/A 25, Road No. 14, Banjara Hills, Hyderabad - 500 034, Andhra Pradesh, INDIA © SQL Star International Ltd.
2.
Copyright © 2008
Second Edition SQL STAR INTERNATIONAL LIMITED SQL Star House,8-2-293/174/A25, Road No.14, Banjara Hills, Hyderabad - 500 034. Tel. No. 91- 40-23101600(30 lines) Fax No. 23101663 Toll Free No: 1800 425 2944 Email: info@sqlstar.com No part of this publication may be reproduced (incl. photocopying) in any way, without prior agreement and written permission of SQL Star International Ltd., Hyderabad. SQL Star International Ltd., Hyderabad assumes no responsibility for its use, nor for any infringements of patents or other rights of third parties which could result. © SQL Star International Ltd. i
3.
Table of Contents
Oracle 10g SQL CHAPTER CHAPTER TITLE PAGE No. NO 1. Database concepts 1-39 2. Introduction to Oracle 10g 40-49 3. Data Retrieval 50-78 4. Enhancing Data Retrieval 79-95 5. Generating formatted reports using isql*plus 96-128 6. SQL single Row Functions 129-154 7. Working with Grouped Data 155-163 8. Joins 164-186 9. Understanding Sub queries 187-201 10. Advanced Sub queries 202-221 11. Data Manipulation 222-248 12. Managing Tables 249-293 13. Managing Constraints 294-318 14. Views 319-342 15. Other Database Objects 343-371 16. Data Dictionary Views 372-380 17. Security Implementation 381-393 18. Manipulating Large Data Sets 394-413 19. Regular Expressions 414-422 © SQL Star International Ltd. ii
4.
Chapter 1
Database Concepts Typical Database Architecture DBMS Types of DBMS Normalization Entity Relationship (E-R) Model Features of SQL © SQL Star International Ltd. 1
5.
Objectives At the end
of this chapter, you will be able to: Understand the basic concepts of a database Identify the disadvantages with Flat File systems Identify the advantages of a DBMS Understand the types of DBMS Understand the E-R Model Understand the features of SQL Describe the Codd‘s Rules © SQL Star International Ltd. 2
6.
Database Management The approach
of the new millennium has brought with it several challenges, thereby making it mandatory for companies and organizations to maintain high level of efficiency in their computing systems, so as to stand the test of time. Databases and database systems are the essential backbone of any organization. Database When one hears the word Database, one thinks of a collection or a store of mutually related data. The implicit properties of a database are as follows: A database represents some aspects of the real world and any changes to the real world should get reflected in the database. For example, a manufacturing concern keeps details of the products it manufactures and also of the suppliers it deals with. Any change in the pricing of the product or a change in the suppliers who supply raw materials must be immediately reflected in the database. A database is a logical collection of relevant data, reflecting some inherent meaning. Any random grouping of data cannot be referred to as a database. A manufacturing concern requires data about its customers, products, as well as its suppliers. Details regarding each of them form a logical group of data. A database is populated with data for a purpose. It has an audience that is interested in its contents. For instance, in the above example, the manufacturing concern needs the customer details to identify its regular customers and also their credit worthiness. Similarly product detail helps in determining the stock depletion level (i.e. when to place fresh order for raw materials). Now a day, the term „database‟ is mostly used in connection with computerized databases. Therefore, today, a study of database systems involves also a study of the associated technology employed to store, access and manipulate the computerized databases. Traditionally, data accessed through computers has been stored on different storage media in the form of individual files. Files proved to be quite satisfactory as long as computerization was limited to a few application areas and the use of computers restricted to a privileged few. However, as actual users grew in number, especially with the advent of online time-sharing systems, the file systems gave rise to many serious problems. The discipline of database systems evolved in response to these problems. Let us first consider what these problems are so as to understand the different features of database systems more clearly. File Systems and the Associated Problems Most data processing systems in existence today, especially in India, use files for storing, accessing and manipulating data. Files are stored typically on magnetic tapes and disks. © SQL Star International Ltd. 3
7.
Most of the
problems with files arise out of the fact that files are specific to an application, e.g., a set of files may be designed for the sales analysis system of a company. Programs of the same application system can use these files. However, if some other new application needs source data from this system, there may be difficulties. Therefore, in many cases, new files, with considerable data in common with the existing files, may have to be designed for the new applications. Therefore, as applications proliferate, the total number of computerized files grows considerably. Also, as the number of actual users of the computer grows, the number of applications increases, in turn resulting in an increase in the number of files. A large number of files give rise to the following problems: Files involve a high level of redundancy in data. As we have mentioned above, proliferation of files results in the same data item being stored at many different places. Redundancy in data often results in inconsistency of data. The same data item being used by different applications may exist in different versions. What is worse, it may exist in different stages of update at different places and thus may have different values. This may ultimately result in inconsistencies amongst reports generated by the two application systems. Individual files are not amendable to rapid changes, especially with respect to the way the data items are structured within the file. If an application wants data from an existing file but structured differently, it cannot be provided quickly and easily. For this purpose, either conversion programs have to be written or new files have to be created. Because of the inflexibility of files, many ad hoc queries cannot be answered. Yet another consequence of the inflexibility of files is that it is usually expensive to make changes to a file system. It is also a very slow process. It may even involve modification of application programs. What is worse, modification in one program may require modifications in other programs, which interface with this program. This process may set off a chain reaction of modifications. The above problems give rise to further difficulties detailed below: The Management Information Systems (MIS) finds it difficult to control data, especially when the actual users develop applications on their own. Major changes required in the system while modifying files increase the maintenance load on Data Processing (DP) professionals substantially, thus making them unavailable for development of new systems. High-level data redundancy entails repetitive data entry and redundant storage with the accompanying costs. © SQL Star International Ltd. 4
8.
As has been
already stated, Database Systems provide an effective solution to the above problems. Let us see how. Data Independence You have just seen, files give rise to several problems because they are application specific. Consequently, the applications become data-dependent, that is, they depend upon the organization and access method for the data on the secondary storage. This happens because, with conventional application development tools such as COBOL, the application logic incorporates the knowledge of data organization and access methods. Therefore, most changes in data organization or access methods affect the application logic substantially. If problems arising due to this fact are to be avoided, the data organization (and the access method) and the application logic have to be made independent of each other. Database Systems do precisely this. The first step towards this goal is to distinguish between data as is actually stored (called as the physical representation of data) and data as is presented to an individual user (called as the logical representation of data). The Physical Representation of Data The smallest named unit of data physically stored in the database is known as a ―stored field‖, and a named collection of associated stored fields is known as a ―stored or physical record‖. The named collection of all occurrences of one type of physical record is known as a ―stored or a physical file‖. This concept will be clearer after we discuss the logical representation of data. The Logical Representation of Data A logical field, record or file is, the field, record or file as it appears to the users, that is, as it is defined in the user‘s application programs. In all traditional systems, the logical and physical data are practically the same, which is the root cause of all the major problems with traditional files. This is not the case with database systems. Similarly, the structure of stored and logical records can be different. A logical record type may be obtained by selectively combining fields from different stored records. The logical and physical views of a file could also be different in terms of, say, the key fields for sequencing the records in the file. With such a separation of the logical and physical data, the database can be modified and developed without affecting existing applications. The database architecture achieves this separation. A Typical Database System Typical database architecture divides the database into three levels of abstraction; the internal, conceptual and external levels. At the internal level is the physical database, while at the external level; one has the different logical views corresponding to an individual application. The conceptual level is an intermediate level, which is a single abstract representation of the entire database. © SQL Star International Ltd. 5
9.
Data Base Management
System (DBMS) is software, which interacts with all the three levels enabling the users to deal with the data in terms of its logical view rather than the actual physical database. A diagrammatic representation of the typical database architecture is shown below: Let us now consider the different individual entities in the architecture in further detail. Let us start with the actual or physical database and see how the architecture brings about a transformation in the data representation to get the data to the user in the form he wants. The Internal Database The internal (or physical) database is stored on secondary storage devices, mainly the magnetic disk. It itself can be conceptually viewed at different levels of abstraction. At its lowest level, it is stored in the form of bits with the associated physical addresses on the secondary storage device. At its highest level, it can be viewed in the form of files and simple data structures. It is this level that we shall study when we discuss the physical organization for databases in later chapters. © SQL Star International Ltd. 6
10.
The physical database
is described by means of a physical scheme or an internal scheme. It essentially describes the various types of stored records, the different indexes that are employed for accessing these and the representations for different stored fields. It is also called as the ―storage structure definition‖. The Conceptual Database The conceptual model, also called as the data model, represents information content of the database in its entirety, but is abstract with respect to the physical database. Broadly speaking, the conceptual model provides a view of the data as it really is. This model consists of multiple occurrences of multiple types of a conceptual record. A conceptual record represents relevant information content only. In this sense, it is much closer to the external record than a stored record is. However, it is not the same as the external record. It contains all the information to build relevant external records. A conceptual stock record may consist of the quantity of material and the buying rate but not its value; still the user‘s external record may consist of the value of the stock. A conceptual model may consist of occurrences of such stock records, a collection of supplier record occurrences and a collection of assembly records. Obviously, the conceptual model is derived from the physical model. For this, the database needs a conceptual/physical mapping, which specifies how conceptual records and fields map into their counterparts in the physical database. The conceptual database is described by means of a conceptual scheme. Needless to say, the conceptual scheme is independent of the physical characteristics of data, such as storage structures, physical sequences, stored field representations etc. Ideally the conceptual scheme should include many features in addition to just the definitions of conceptual records. These may include relevant authorization checks and validation procedures, the uses of data, the source and destination of data etc. The conceptual database is a real-world view of data from the organization point of view. As the real world changes, changes have to be made to the conceptual database and scheme as well. In such a case, it is usually possible to limit the corresponding changes to only those external schemes, which use the conceptual elements that are changed. The External Database The external model (or view) is application-specific. Therefore, the user views the database through an external model, and there are as many external views as there are applications. External views are the proper interface between the user and the database as an individual user can hardly be expected to be interested in the entire database. Generally, an external model consists of multiple occurrences of multiple types of external record. An example of an external record is the record of a file as defined in the data division of COBOL program. Each external model is defined by means of an external scheme, which describes each external record type in the external model. The external model is derived from the conceptual model. For this purpose, the correspondence between the particular external models has to be defined. An © SQL Star International Ltd. 7
11.
external/conceptual mapping similar
to the conceptual/physical mapping does this. However, a separate mapping has to be defined for each external view. An explicit definition of the mapping should be documented, preferably in the corresponding external scheme. The user interacts with the database through a high-level language such as COBOL, PL/I or some special purpose language. This language is known as the host language. It includes a data sub-language (DSL). The user carries out the retrieval and storage operations on the database through the DSL. In fact, the Database Task Group (DBTG) report published in April 1971, contains proposals for three distinct languages, two of which relate very closely to the concept of a DSL. These are sub scheme Data Description Language (DDL) and Data Manipulation Language (DML). The sub scheme DDL is used for defining the external views while the DML is used for carrying out operations on the database. In addition to the languages, the user is also supposed to be provided with a workspace. This workspace is an area meant for receiving or transmitting all data transferred between the user and the database. This is simply the input-output area for a program. Let us now consider what a database management system is, which interacts with the three levels and the mappings. What is a Database Management System? The DBMS is the software, which handles all accesses to the database. Conceptually, if a user requests a certain data item, the DBMS intercepts and interprets the request, retrieves the relevant stored occurrences from the physical database, constructs the required conceptual record occurrences using the physical/conceptual mapping, then derives the required external record occurrence from the conceptual records constructed using the relevant conceptual/external mapping. Advantages of DBMS You have seen that data independence and the consequential benefits are both an essential feature and a major advantage of database systems. Yet another essential feature is the centralization of related data. This phenomenon results in further advantages of database systems. These are: The stored data can be shared relatively easily New applications may be developed using the existing database Standards for representation of data can be laid down and enforced among different installations. This can significantly reduce the maintenance activity and enhance data compatibility among installations. With a centralized control of data, the database system may be designed for an overall optimal performance from the viewpoint of the entire organization. © SQL Star International Ltd. 8
12.
Ensuring data security becomes much easier as access to the database can be controlled through establishment of proper channels and authorization checks. However, to realize the above benefits, proper organizational infrastructure is needed. The most popular way to support the Database environment is to establish the office of the Database Administrator (DBA). In fact, the DBA may be a single person or a team. He is responsible for the centralized control of the database. The Database Administrator The database administrator is responsible for the overall planning of the company‘s data resources, for the design of data, and for the day-to-day operational aspects of data management. The overall planning of corporate data is the strategic aspect of the database administration function and involves company-wide planning of existing data and assessment of organization-wise data standards. Some of the design aspects of database administration work are: Deciding on the storage structures and access methods Selecting database software and hardware Designing restart and recovery procedures to take care of system outages or crashes Designing means of reconstructing data in the event of abnormal loss of the same Designing scheme Designing the means of reorganizing or tuning databases periodically Designing database searching strategies Designing authorization checks and validation procedures Specifying techniques for monitoring database performance The operations management of database administration deals with data problems arising on a day-to-day basis. Specifically, the responsibilities include: Investigation of errors found in the data Supervision of restart and recovery procedures in the event of a failure Supervision of reorganization of databases Initiation and control of all periodic dumps of data. © SQL Star International Ltd. 9
13.
In addition, this
aspect of database administration includes maintenance of data security, which involves maintaining security authorization tables, conducting periodic security audits, investigating all known security breaches. To carry out all these functions, it is crucial that the DBA has all the accurate information about the company‘s data readily on hand. For this purpose he maintains a data dictionary. The data dictionary contains definitions of all data items and structures, the various schemes, the relevant authorization and validation checks and the different mapping definitions. It should also have information about the source and destination of a data item and the flow of a data item as it is used by a system. This type of information is a great help to the DBA in maintaining centralized control of data. Types of DBMS The different types of DBMS available are: Hierarchical database management system Network database management system Relational database management system Object Relational database management system Hierarchical DBMS Hierarchical DBMS (HDBMS) is one of the oldest methods used for organizing and storing data. In a hierarchical database, data is organized in a pyramid fashion, just like the branches of a tree extending downwards. In a hierarchical database you need to understand the concepts of record type and parent-child relationship. Let us take an example. In the order processing of any organization, orders are placed for different products. Orders comprise the following information, which are also called field values: • Order number • Order date © SQL Star International Ltd. 10
14.
•
Customer number • Product number Similarly, products comprise a collection of: • Product number • Product type • Product name • Quantity • Price The collections of these field values are called records and groupings of records of the same type are called record types. Related records are grouped together so that you can have higher-level records and lower-level records, similar to how the parents in a family tree sit above the subordinated children. In the example, Orders and Products are the two record types and the relationship between them is the parent-child relationship. Hierarchical Database Management System In the diagram, the parent record (Orders) at the top of the pyramid is called the root record. The parent record has three child records linked to it. The root of the hierarchical model cannot act as the child record type. Except the root, every record type acts as a child record type in exactly one parent-child relationship. The child records can have only one parent record. In contrast, a parent record may have more than one child record linked to it. Each child record can also be a parent with child records underneath it. Hierarchical DBMS works by moving from the top of the pyramid to its bottom. A record search is conducted by working down through the pyramid from parent to child until the suitable child record is found. The pyramid like structure and the defining of relationship between records in advance makes it easy to access and update hierarchical databases. © SQL Star International Ltd. 11
15.
However, there are
few limitations with HDBMS. The relationship between child records is not permitted, even if they make a logical sense. Moreover, the hierarchical design is so rigid that adding a new record requires the redefinition of the entire database. Network DBMS Network DBMS (NDBMS) is an extension of HDBMS. Instead of having a pyramid like structure, a NDBMS looks more like a spider web or interconnected network of records. In NDBMS, child records are called members and parent records are called owners. In the network data model too, data is stored in records and descriptions of the structure of a group of records of the same type are stored in record types. Record types are linked or related using the set types. Set types consist of: • A set type name • An owner record type • A member record type Consider an example of orders and it‘s products. The two record types are Order and Product, the former being the owner record type and the latter being the member record type. They are linked using the set type ProdOrder, which represents the relationship between orders and products in them. The relationship is of 1:N meaning that there will be many set occurrences (or instances) where one record from the owner record type Order relates to a set of records from the member record type Product. That is, an order can have one or more products in it. Therefore, set occurrences are composed of: • One record from the owner record type • A number of records (zero or more) from the member record type Network Database Management System © SQL Star International Ltd. 12
16.
In the figure
there are three set occurrences of ProdOrder set type, which are Product1, Product2, Product3. A record of the member record type cannot exist in more than one set occurrence, that is, two customers cannot buy the same product. Similar to HDBMS, NDBMS structure and relationship must be defined in advance. The number of connections that can be made between records is also limited. Relational Database The databases mentioned so far including the file system databases were not very efficient. In the file system, users cannot simultaneously access data from the same file, managing the files is very tedious when data stored is complex and accessing data from files is also very tedious. HDBMS and NDBMS does not allow many-to- many relationships, has complex path to navigate and retrieve data, and the relationship between data is in the form of pointers. The objective of developing the relational model was to overcome the shortcomings of those systems that existed at the end of the 1960s, and to make DBMS products more appealing to all kinds of users. Dr. E. F. Codd first introduced the relational model when he proposed the relational model principles in a paper called ―A Relational Model of Data for Large Shared Data Banks‖ in June 1970. A relational database stores data using relations where each relation resembles a table of values. Each row in a table contains collection of data values. For example, a university stores information about all it‘s students using tables referred to as a Student table and a Course table. Student table contains details about students, such as, their student number, name and the course code. As different data is stored in the two tables, we may need to combine them to answer particular questions such as details about students pursuing course ‗Electronics‘. An RDBMS enables to relate data in one table to the data in another. It does so by identifying the relationships, which are represented by primary key and foreign key. A primary key is assigned to that column, which will enable you to identify each row of data in a table uniquely. For example, in the Course table the column containing the course code is the primary key as it helps to identify each course uniquely. A foreign key is assigned to a column of a table, which refers to the primary key column in another table. For example, in the Student table the column containing the course code refers to CourseCode column of the Course table. © SQL Star International Ltd. 13
17.
Object Relational Database Hierarchical,
network and relational database models have been quite successful in storing data for traditional business applications. But, object oriented databases evolved to handle more complex applications such as databases for scientific experiments, geographic information system, engineering design and manufacturing. An object oriented database stores data, their relationships and the way they interact with other data. As compared to the relational database approach, which deals with data at the lowest level, that is, columns and rows, the object oriented approach deals with data at a higher level, that is, with the objects surrounding the data. RDBMS Dr. E.F.Codd outlined the principles of the relational model, which formed the basis for the evolution of the Relational Database Management System. A Relational Database Management System is defined as a collection of tables related to each other through common values. Evolution of RDBMS Before the acceptance of Codd‘s Relational Model, database management systems was just an ad hoc collection of data designed to solve a particular type of problem, later extended to solve more basic purposes. This led to complex systems, which were difficult to understand, install, maintain and use. These database systems were plagued with the following problems: They required large budgets and staffs of people with special skills that were in short supply. Database administrators‘ staff and application developers required prior preparation to access these database systems. End-user access to the data was rarely provided. © SQL Star International Ltd. 14
18.
These database systems did not support the implementation of business logic as a DBMS responsibility. Hence, the objective of developing a relational model was to address each and every one of the shortcomings that plagued those systems that existed at the end of the 1960s decade, and make DBMS products more widely appealing to all kinds of users. The existing relational database management systems offer powerful, yet simple solutions for a wide variety of commercial and scientific application problems. Almost every industry uses relational systems to store, update and retrieve data for operational, transaction, as well as decision support systems. Basic Relational Database Terminology In a relational database, the entities of the ERD are represented as tables and their attributes as the columns of their respective tables in a database schema. The components of a database schema include: Tables: Tables are the basic storage structures of a database where data about something in the real world is stored. It is also called a relation or an entity. Rows: Rows represent collection of data required for a particular entity. In order to identify each row as unique there should be a unique identifier called the primary key, which allows no duplicate rows. For example in a library every member is unique and hence is given a membership number, which uniquely identifies each member. A row is also called a record or a tuple. Column: Columns represent characteristics or attributes of an entity. Each attribute maps onto a column of a table. Hence, a column is also known as an attribute. Relationship: Relationships represent a logical link between two tables. A relationship is depicted by a foreign key column. Some optional properties of relational tables include the following: Data items (fields) must have a single value. Data values in columns are of the same kind. This property states that all values in a given column must come from the same domain. Let us understand the concept of a domain. Suppose, you have a CourseName column in the Course table, which is defined to be a character string of length 15. The possible values this column could have are: Oracle10g Java E-commerce C++ © SQL Star International Ltd. 15
19.
Visual Basic Let us name this list as ‗course-names’ and define a rule that the contents of CourseName should not only be characters of length less than 15, but must also contain values that are part of ‗course-names’. Here, ‗course-names’ becomes the domain and CourseName is in the domain of ‗course-names’. Each row is unique The sequence of columns (left to right) is insignificant. The benefit of this property is that columns can be retrieved in any order. The sequence of rows (top to bottom) is insignificant. The benefit of this property is that rows can be retrieved in any order, that is, the third, fourth or fifth row of member details could be retrieved. Each column must have a unique name. As mentioned above, the sequencing of columns being insignificant, columns must be referred by name and not by their position. Normalization One of the methods of designing a database is normalization of steps. What do you mean by normalization? Normalization can be defined as the technique implemented to remove redundancy from an existing set of tables. Normalization helps: Reduce redundancy Increase integrity Stabilize design Identify any missing data A relational table is normalized if it satisfies a certain set of constraints, which are that they should be free of data redundancy and that they can be modified consistently and correctly. Therefore, normalization is the process of removing redundant data by splitting a table into smaller tables. The technique of normalization includes some rules, which when applied, changes un-normalized data to a structured and normalized state. The process of normalizing is implemented in levels called normal forms. There are three such stages, they are: First normal form Second normal form Third normal form © SQL Star International Ltd. 16
20.
First Normal Form
(1NF) The first normal form can be defined as the level where the tables represent a set of two-dimensional structures and contain no repeating groups. You need to implement the following set of steps to convert your un-normalized data to its first normal form. Identify the primary key Remove all repeating columns Create a new table to contain the repeating columns Add a primary key column to the newly created table so as to ensure uniqueness Add a foreign key column to the new table. It should be the same column at the primary key in the base table. To understand better, follow the example given. Example To arrive at a functionally efficient library database schema, you would have to normalize the tables of the library database. The main table used in the library is where the transaction details will be stored. You would require: All information pertaining to the customers who borrow books All information of the borrowed book, such as its author, its publisher‘s information and the dates of issue and return The un-normalized table is as follows © SQL Star International Ltd. 17
21.
© SQL Star
International Ltd. 18
22.
This table can
be brought to the 1NF by removing all the repeating columns. The repeating columns are put into separate tables in logical groups with a primary key as a unique identifier for each table. The tables in the first normal form are: Second Normal Form (2NF) The second normal form can be defined as the level where tables are in the 1NF, and where for every table, all its non-primary key columns are dependent on the whole primary key. A column should not be partially dependent on the primary key. When a column depends on part of the primary key it is called partial dependency. To remove partial dependency: 1. Identify the non-primary key columns and remove them from the tables 2. Create another table to contain the removed columns, and the primary key column that they are dependent on. To bring a table to the 2NF, any of the following rules should be met: The primary key column should not be a composite key. That is, it should be made up of only one column. All the non-primary key columns are dependant only on the primary key. There should be no non-primary key dependent columns in the table. To bring the tables to 2NF, remove all those columns that are partially dependent on the whole primary key. For instance the book availability does not depend on the transaction ID but only on the book ID. So that column can be removed into a new table. Hence, the tables in the second normal form will be as follows: © SQL Star International Ltd. 19
23.
Third Normal Form
(3NF) The third normal form is defined as the level where the non-primary key columns in the tables are directly dependent on the primary key and are not dependent on any other non- primary key. If you remove the transitive dependencies from a table in 2NF, then it is said that, “the non-primary key columns are dependent on the primary key, the whole key and nothing but the key”. Steps to convert a table to the third normal form are: 1. Identify the non-primary key columns that depend on other non- primary key columns. 2. Remove the columns arrived at in the first step from the base table. 3. Create another table with the removed columns and include the non-primary key column that they are dependent on making it the primary key. 4. Create a foreign key in the base table linking it to the primary key in the new table. © SQL Star International Ltd. 20
24.
To bring the
tables to their third normal form remove the non-primary keys that are dependent on other non-primary keys and also remove the columns that are calculated or derived columns. The membership fee a non-key column depends on the age of a member, which is another non-key column. Tables in the third normal form are: The Entity Relationship Model The conceptual level model is a very important model in typical database architecture. To represent or model data at this level, three major data models namely, network, hierarchical and relational, have been proposed which you shall examine later. Each of these models has its own pros and cons. The entity relationship model is not a formal data model, unlike the three mentioned above. However, this model is a more natural view of the real world, which consists of entities and relationships, as you shall see shortly. Therefore, this model is very useful for understanding the concept of data modeling. The three formal models employ certain ways of representing data known as data structures; essentially to represent the ―entity relationships‖ existing in the real world. The entity relationship model (E-R model) clarifies concepts regarding what entity relationships are, and what modeling entity relationships existing in the real world means. Therefore, a study of the E-R model should be an appropriate first step towards understanding the three major data models. © SQL Star International Ltd. 21
25.
Entities An entity is
a thing, which can be distinctly identified. What is important over here is that it is individually distinct. Employees, a house, a supplier to an organization, are all entities. Identification of entities relevant to a database is extremely important, because, a database contains data about entities. All entities of the same type form an entity set. ―All Employees‖ form an entity set and so do ‗All Suppliers‘. Distinguishing Entities As has been stated, an entity is a distinctly identifiable thing. To distinguish one entity or one member of an entity set from another, one needs some means of distinction. This distinction is achieved through values of what is known as the ―Key Attribute‖ of the entity. The database gives information about different entities contained in it. This information is about different properties of each entity. For example, a personal database contains information about employees (here employee is the entity). The properties of an employee about which information is given, may typically be, employee number, name, date of birth, date of joining the organization, total job experience and educational qualifications. Each of these properties is called an attribute of the entity. Each of the attributes can take on a value from a range of possible values, which is known as the domain of values for that attribute. The values need not be only numerical but may also be character strings. For each entity in an entity set, there is an attribute, which distinguishes the entity uniquely from the other members of the set. This attribute is the key attribute for the entity-set. For example, the employee entity-set discussed about can have either the employee number or the employee name (assuming no two names are identical) as the key attribute. In some cases, a combination of more than one attribute may act as a key, instead of just one key attribute. Some times, an arbitrary serial number may have to be supplied as the key attribute. There are special cases where the members of an entity-set can be distinguished from one another only by their relationship to entities of another type. The ‗is a‘ relationship is one such relationship. These cases will be illustrated when we take up an actual example of an E-R model later. Relationships In a real-world situation, certain entities are associated with each other. For example, referring to the employee entity-set will have a relationship with the department entity-set signifying the department for which an employee works. This relationship can be expressed as the ―works-for‖ relationship from ―employee‖ to ―department‖. A relationship may exist amongst the members of the same entity-set. For example, in the employee entity-set, some employees may be seniors of certain other employees. Therefore a relationship ―senior-of‖ may exist between one member of the employee entity-set and a few other members of the same set. © SQL Star International Ltd. 22
26.
A diagrammatic representation
for the employee-department relationship may be as given below. A diagrammatic representation for the ―senior-of‖ relationship may be: It should be noted that relationships convey very important information regarding the relevant real world situation just as entities do, and hence should be properly represented. There may also be relationships involving more than two entity sets. For example, Prof. Smith teaching Economics to a student named Sam. This relationship contains two relationships – (1) Prof. Smith teaches Economics and (2) Prof. Smith teaches Sam. These two relationships cannot be combined to deduce the information given by the original relationship. The same entity-sets may be also linked by more than one relationship. For example, the Professors and the Students entity-sets may be linked by the two relationships, viz; (1) TEACHES and (2) ADVISOR-O Types of Relationship Relationships between the entity-sets can be classified according to how many members of one entity-sets are related to one member of the other entity-set and vice-versa. Accordingly, the following types of relationships can be identified. One-to-One Relationships If a one-to-one relationship exists between two entity-sets A and B, it means that with each entity in A, at most one entity in B is associated and vice-versa. Strict one-to-one relationships are not very common in real world situations. Consider an entity set of traffic policemen and another entity-set of traffic control points in the city and assume that only one policeman controls one traffic control point. Under this assumption, the relationship CONTROLS between the entity sets POLICEMEN and CONTROL-SITES will be a one-to-one relationship. Many-to-one Relationships This type of relationship is quite common in everyday life. If, with each entity in the entity-set B, zero or more entities in set A are associated, then we say that a © SQL Star International Ltd. 23
27.
many-to-one relationship exists
from set A to set B. In our earlier employee database example, the WORKS-FOR relationship is a many-to-one relationship from the entity-set EMPLOYEES to the entity-set DEPARTMENTS (assuming that an employee works for only one department at a time). Many-to-Many Relationships This is yet another type of relationship which is quite common in real-life situations. In this case, associated with each entity in set A, there may be zero or more entities in set B and vice-versa. A very common example of this type would be the relationship between the entity-set SUPPLIERS and the entity-set PARTS. A supplier may supply many parts, while a part may be supplied by many suppliers. Guidelines for Constructing the Entity-Relationship Model Having understood the basic components, you are now in a position to consider the construction of an E-R model. The principal steps involved in this exercise are: • Select relevant entity-sets for the real-life situation under consideration • Select relevant attributes for each entity-set • Identify the key-attribute for each entity-set • Determine the type of each of the relationships between the entity sets • Draw the E-R diagram Consider the situation in which the academic administration often finds itself. It has to handle data regarding students, faculty, and the courses being offered, and possible areas of specialization. It is worthwhile to consider the following points before you move to construct the model: • The students specialize in one or more areas • The students study a specific course • A course belongs to an area of specialization • A faculty member belongs to an area of specialization • A student can be either a doctoral student or a degree student • A faculty member guides a doctoral student • Certain courses have certain other courses as prerequisite • A faculty member offers a specific course From the above, the desirable entity-sets, their relevant attributes and the appropriate key attributes can be determined. 1. Entity-set : Students Attributes : Roll No, Name, Date-of-birth, Basic Educational Qualification, No. of years of work experience © SQL Star International Ltd. 24
28.
Key
: Roll No. 2. Entity-set : Faculty-members Attributes : Name, Date-of-birth, Date of Joining, Educational Qualifications, Total No. of years of Teaching Experience Key : Name 3. Entity-set : Courses Attributes : Course-No, Course-Name Key : Course-No 4. Entity-Set : Areas (of specialization) Attributes : Name of the Area Key : Name of the Area 5. Entity-Set : Doctoral-students Attributes : None This entity-set is needed to identify individual doctoral students. The reason for assigning a separate entity-set to doctoral students is to be able to establish the relationship between these students and their faculty guides, in the actual database. Now you are in a position to identify the different relationships amongst the above entities. These are: 1. SPECIALISES_IN: This is a many-to-many relationship between STUDENTS and AREAS 2. STUDIES: This is a many-to-many relationship between STUDENTS and COURSES 3. INCLUDED_IN: This is a many-to-one relationship from COURSES to AREAS 4. BELONGS_TO: This is a many-to-one relationship from FACULTIES to AREAS 5. GUIDES: This is a one-to-many relationship from FACULTIES to DOCTORAL- STUDENTS 6. OFFERS: This is a many-to-many relationship from FACULTIES to COURSES. The assumption here is that a course may be offered by more than one faculty-member 7. IS A: This relationship is one-to-one between STUDENTS & DOCTORAL-STUDENTS 8. PREREQUISITE_FOR: This is a many-to-many relationship from COURSES to COURSES because a course may be a prerequisite for more than one other course and may have more than one other course as prerequisites for itself Now you are ready to draw the E-R diagram representing the E-R model. First let us discuss the relevant diagrammatic conventions and then actually draw the diagram © SQL Star International Ltd. 25
29.
Conventions for Drawing
E-R Diagrams Following are the conventions for drawing E-R diagrams: · Entity-sets are represented by rectangles. · Attributes are represented by circles. These are linked to the appropriate entity-sets by undirected edges. · Relationships are represented by diamond shaped boxes. These are linked to the appropriate entity-sets by directed edges. An E-R diagram for the Academic Administration database is: As already stated earlier, the E-R model brings out the essential features of data modeling for databases. Data modeling in practice, is done according to the one of the three models, viz., hierarchical, network and relational. The three models too, establish relevant entities and the relationships amongst them; they differ in the way they represent data about both entities and their relationships. The E-R model, however, is free from these relatively physical aspects of data representation and therefore can be said to be a general view of the three models unifying them at a relatively abstract level. Case Study – Entity Relationship for a Library The library needs to create a database to automate its data storage and processes. For this you first need to know how a library functions, what are its transactions and what data it needs to store for activities. To arrive at an ERD for a library, list the entities and its attributes you require before putting them into a diagram: Member Member ID Name © SQL Star International Ltd. 26
30.
Address Area Zipcode phone number Age Date of membership Age group Branch ID Book Book ID Book name Author name Publisher Published Year Category Branch No of copies in store Transaction Transaction ID Member ID Book ID Issue date Return date The actual return date Fine to be paid by the member for default Category (for books) Category ID © SQL Star International Ltd. 27
31.
Category description
MemberFee Age group grade Minimum value Maximum value Fee amount Branch Branch ID Branch name Address Location Phone number Date of establishment Availability Book id Available copies Publisher Publisher Id Name Address The list arrived at above can be depicted as an ERD in the following manner: © SQL Star International Ltd. 28
32.
Communicating with RDBMS In
order to communicate with the RDBMS, that is, to access data, you have a query language called a Structured Query Language (SQL). A query can be defined as a request made to access data from the database. This definition refers not only to data retrieval, but also defining, manipulating and controlling data. The need to access data from the database on an ad-hoc basis led to the origin of SQL. The origin of SQL can also be associated with one of Codd‘s Twelve Rules, where in he states that a relational database must have a high level language capable of handling all communication with the database. Although there are several languages that can access data from the database, SQL is the primary language for communicating with RDBMS. SQL can also operate on non-relational databases. © SQL Star International Ltd. 29
33.
Features of SQL The
features of SQL are as follows: • SQL is a Declarative Language (non-procedural). You need not provide the Step wise procedure to be followed in order to access the data. Instead, it allows you to simply declare what data you want without having to provide details about where it is located or how to get it. It leaves it to the DBMS to determine the best way to get it. On the contrary, procedural languages such as C, or C++ provide a step-wise procedure telling the computer exactly what is to be done. The advantage being that these instructions given ahead of time can be compiled into machine language for fast execution. But these languages lack flexibility, that is, do not adapt to changes easily. • SQL is a set-based language. Since the relational model uses the concept of a mathematical relation that is, has its theoretical basis in set theory, SQL supports set operations and relational algebra operations. A set is an unordered collection of elements of the same type and structure. Tables (or relations) are called sets and rows (or records) are their elements. In a relational database the physical positioning of rows is not important, that is, they are unordered, so SQL being a set-based language can operate on an entire table, or multiple tables at once. In contrast, a procedural language can operate on a single record at a time as it uses ‗files‘ which are similar to tables, wherein records have a physical ordering. Relational algebra operations can be divided into two groups: Set operations from mathematical set theories including Union, Intersection and Set Difference. Operations developed for relational databases, which include Select, Project and Join. Set Operations Set operations include the following: Union Intersection © SQL Star International Ltd. 30
34.
Set Difference Union To
understand the union operation look at the following two tables, States1 and States2: The above two tables contain names of US states. Some of the state names are common in both the tables. In order to return the state names that are in States1 or in States2 or in both States1 and States2, eliminating duplicate rows, you use the UNION operation. The notation for union of tables is: States1 UNION States2 = States3 The result of the union operation is as follows: States 3 Hawaii New Jersey Indiana Florida Arizona Colorado California Alaska Texas Georgia Virginia Wisconsin Kansas Kentucky Iowa The resulting table contains the state names that are contained in both the tables, but displaying the common state names only once. © SQL Star International Ltd. 31
35.
Intersection The intersection operation
returns state names that are in both States1 and States2, that is, it returns a third table that contains only common state names. The notation for intersection of tables is: States1 INTERSECTION States2 = States3 The result of the intersection operation is as follows: Set Difference The result of the set difference operation returns state names that occur in the States1 table but not in the States2 table, or also vice versa. The result is as follows: Relational Operations In addition to set operations, certain other operations were developed for relational databases, which include: Selection Projection Joins Selection The selection operation enables you to retrieve only specific rows that match your criteria. For example, you have two tables TabA and TabB. © SQL Star International Ltd. 32
36.
Using the selection
capability of SQL, you can retrieve those rows from TabB table where Col1 value is 2. The result set of rows would be: Projection The projection operation enables you to retrieve only specific columns from the total columns available. For instance, using the projection capability of SQL, you can retrieve only Col2 values from TabA table. The result set would be: Joins The join operation enables you to retrieve data from more than one table. For instance, using the joining capability of SQL, retrieve rows from both TabA and TabB by joining Col1 as they have equivalent values. The result set of joining the two tables would be: Why SQL is Preferred? SQL is favored due to the following reasons: © SQL Star International Ltd. 33
37.
A wide range of users, including those with little or no programming knowledge can use it. It is an English-like language. It is non procedural, that is, the user need not specify the method to be followed to arrive at the result, rather just specify the result that needs to be arrived at. It allows defining, retrieving and manipulating data in the tables. Relational Data Model Concept This rule states that all data is represented as tables. Data can be viewed in no other way. Codd’s Rules Dr. E. F. Codd, was the creator of the relational data model. It was published as a two- part article in ComputerWorld (Codd, 1985). It contains a list of 12 rules that determine whether a DBMS is relational and to what extent it is relational. These rules are a very useful yardstick for evaluating a relational system. In the article, Codd mentions that according to these rules, there is no database yet that is fully a relational system. He says that rules 6, 9, 10, 11 and 12 are difficult to satisfy. Each of the twelve rules is briefly discussed below. The Information Rule All information in a relational database is represented explicitly at the logical level and in exactly one way through values in tables. Guaranteed Access Rule Each data item must be accessible by providing table name + primary key of the row + column name. © SQL Star International Ltd. 34
38.
Systematic Treatment of
Null Values Handle missing or non-applicable data, that is, nulls, in a consistent manner. Nulls should have no values and should simply be missing data. Treating Null as a zero for missing numeric data or as a blank for missing character data violates this rule. Vendors provide the ability to use default values for missing data, if so desired. Self-describing Database In addition to storing user data, a relational database must contain data about itself. There are two types of tables in RDBMS: user tables, which contain data required by users, and system tables, which contain data about the database structure. The data that describes the database structure is called meta-data. The collection of system tables is called as the system catalog or data dictionary. Storing any part of the data dictionary in operating system files would violate this rule. Comprehensive Data Sublanguage The data access language (SQL) must be the only means of accessing data stored in the database. The language must support relational operations and set operations with regard to the following: Data definition Data manipulation Integrity definition Transaction control Data control Accessing data files (files that contain the actual data), through a utility other than an SQL interface, violates this rule. View Updating Rule There are situations where users may require only a part of the table information or information from a collection of tables. Such requirements can be met by creating ‗Views‘. Views are virtual tables, which unlike a table contains no data, just statements that return data in the form of tables. This rule states that views should allow updates in the underlying tables and vice versa. But SQL supports only updates of single tables at a time (see rule 7), therefore if, you join three tables to create a view, and try to update that view, then DBMS would fail to translate these updates to the underlying tables, thereby violating this rule. Also, a view not including the column that uniquely identifies each record in a table cannot be updated, thus violating the rule. This rule will be dealt in depth in the chapter on ―Views‖. High-level Insert, Update and Delete This rule states that in a relational database, the query language (SQL) must be capable of performing manipulations (such as, inserting, updating or deleting data) © SQL Star International Ltd. 35
39.
on sets of
rows in a table. A database that supports only row-at-a-time manipulation cannot be considered as relational. Physical Data Independence This rule states that in a relational database, any changes made in the way data is physically stored (that is, data stored in file systems specific to the machines operating system) must not affect applications that access data. If a file supporting a table was moved from one disk to another or renamed, then this should have no impact on the application. Logical Data Independence This rule states that changes to the database design should be done in a way without the users being aware of it. The change could be to expand the database (adding a new table) or to reduce it, but the application that refers to the data (logical) must work as before. If a single table were split into two, then a view would have to be provided joining the two back together so that there would be no impact on the application. Integrity Independence In order to be considered as a relational database, all data integrity, which are definable in the query language referred to in rule 5 must be stored in the database as data in tables, that is, in the catalog and not in the application programs. The data integrity rules that should apply to relational databases are: Entity integrity- the primary key column cannot have missing values Referential integrity- for every foreign key column value there must exist a matching primary key column value. Integrity rules are covered in depth in a later chapter. Distribution Independence In a relational database, data can be stored centrally (on a single system) or distributed (across a network of systems). The data in a centralized database should remain logically unaffected if they are distributed across systems. For example, a user should be able to retrieve data from two tables distributed across two terminals, the same way, as they would retrieve them if stored in the same terminal. Non-subversion Rule This rule states that there should be no other access path to the database, other than SQL. Any other access language may bypass (or subvert) security or integrity rules, which otherwise would be obeyed by the regular data access language. © SQL Star International Ltd. 36
40.
Summary In this chapter,
you have learnt that: Files prove to be inefficient due to their redundant nature when the number of applications increase. This gave rise to the concept of Database. Database is a collection of logically related data stored on media. To handle and maintain this database, a software, Database Management System (DBMS) came into existence. They are of 4 types: 1. Hierarchical Database Management System 2. Network Database Management System 3. Relational Database Management System 4. Object Relational Database Management System Out of these types, Relational Database Management System (RDBMS) was popularly used which enables to relate data in one table to the data in another. Normalization is the process to stabilize a database, by reducing data redundancy. Data can be stabilized through 3 stages: 1. First Normal Form (1NF) 2. Second Normal Form (2NF) 3. Third Normal Form (3NF) To access the stabilized data, Structured Query Language (SQL) is widely used. © SQL Star International Ltd. 37
41.
Lab Exercise In the
following questions, you are given the Universe of Discourse (UOD, that is, the general outline at the level a user would normally describe) of some typical enterprises. Please note that a UOD is not a smooth and structured description. Define: Entity and associated attributes Relationships between entities and type of relations Draw the Entity-Relationship diagram 1. LIBRARY SYSTEM: A library keeps records of current loans of books to borrowers. Each borrower is identified by a borrower number and each copy of a book by an accession number. The name and address of each borrower is held so that overdue loan reminders etc., can be sent whenever necessary. The information required about books is the title, authors, publishers, publication date, International Standard Book Number (ISBN), purchase and price and current price. There is a restriction on the number of books a borrower may have on loan at any one time, the limit depending on whether a borrower is classified as having junior or adult status. Books out on loan may be reserved by other borrowers pending their return. The library stocks only the hardback version of the book. If a new edition of the book is published, all copies of earlier editions are withdrawn from stock. 2. A UNIVERSITY: A University has number of departments. Each department has its faculty. Departments enroll students. Each faculty member may conduct one or more courses and one or more students register for a course. The courses are conducted in classrooms based on a prepared time-table. Each subject has a prescribed text book and host of recommended reference books. A faculty member may guide more than one project and the same project may be done by more than one student. 3. DEPARTMENTAL STORE: The data in the database of a department store are defined as follows: Each employee is represented. The data about an employee are his employee number, name, address and the department he works for. Each department is represented. The data about departments are its employees, manager and items sold. Each item sold is represented. The data about items are its name, manufacturer, price, model number (assigned by the manufacturer) and an internal item number (assigned by the store). © SQL Star International Ltd. 38
42.
Each manufacturer is represented. The data about a manufacturer are its name, address, items supplied to the store and their prices. Various employees work for a department and each department stores items supplied by various manufacturers. A MANUFACTURING ENTERPRISE: A manufacturing company consists of a number of divisions. Each division, in turn, consists of one or more departments. Each employee of the company belongs to only one department at any point of time. Orders are executed at the divisional level. Any number of departments (as required) may execute an order. A department may also execute a number of orders. Employees work on various orders in the organization. An order needs several parts. A part may be needed by several orders. A part itself may consist of sub parts. Alternatively, a part may be a support of a super part. Parts are housed in warehouses which are at specific locations. Suppliers supply parts. AN AIRLINES ENTERPRISE: An Airlines company has a fleet of aircraft‘s which it employs to carry passengers from one airport to another. A flight (i.e. an aircraft assigned for trip from one airport to another) is manned by a crew. A time table is available for all the flights. At each airport, based on the flight schedules, service schedules are drawn up for the ground staff. At each airport, for each flight, caterer(s) provide the necessary food and refreshments according to the catering schedule. The maintenance of aircraft‘s (that are not in operation and which have been tagged for maintenance) is done by the maintenance staff according to the maintenance schedule. Maintenance is conducted at the airports where hangar(s) are available for the type of aircraft in question. © SQL Star International Ltd. 39
43.
Chapter 2
Introduction to Oracle10g Key features of Oracle10g Components of Oracle10g © SQL Star International Ltd. 40
44.
Objectives At the end
of the chapter, you will be able to: Identify the different components of Oracle10g Identify the enhanced features of Oracle10g © SQL Star International Ltd. 41
45.
Introduction The traditional database
systems such as relational, hierarchical and network have been successful in developing the database for traditional business applications such as banking and railway reservations. But, when it comes to more complex business applications such as databases for scientific work, engineering designs, telecommunications, geographic information system and multimedia, the traditional database systems cannot handle them because the requirements and characteristics of these applications are different from the traditional business applications. These applications require more complex structures for: Storing data related to real world objects such as engineering diagrams, molecular structures, or financial instruments Transactions, which would be for longer durations New data types required for storing complex multimedia data such as audio and video clips, images and maps. Oracle10g Database meets the above needs as it tightly incorporates ORDBMs concepts. Object Relational Database Management System (ORDBMS) is a database management system that has evolved from the relational model and includes both the relational and object-oriented technology. Oracle8.0 was the first version of the Oracle database to incorporate object-oriented technology. In Oracle10g, ‗g‘ stands for GRID. This release is focused on efficient management of infrastructure based on its grid computing mechanism. Now, the question arises what is Grid Computing? The idea behind the grid computing is to utilize the resources available, to the maximum extent by dynamically pooling it based on the requirement of the end user during the peak hours. In this case, the end user need not know the whereabouts of the resource. Infrastructure Advantages Data Availability Internet database availability is critical for any eBusiness application. Oracle10g focuses on the following areas to achieve continuous data availability: Zero data loss data protection environment Support for online reorganization and redefinition architecture to reduce offline maintenance requirements Provides more complete and precise database repair capabilities by ensuring better prevention and improved handling of disk corruption © SQL Star International Ltd. 42
46.
Scalability and Performance Oracle10g
enables eBusiness to scale millions of users performing millions of transactions per hour by focusing on the following key areas: Transparent cluster scalability and performance: Oracle10g along with its grid mechanism includes Real Application Clusters (RAC) that has been designed to provide continuous data availability while increasing the scalability and performance of the database infrastructure. RAC was introduced in Oracle9i, which is an arrangement, where a single database runs on a group of servers that are clustered together. With Oracle9i RAC all servers in the cluster act as backup to each other while at the same time increasing the overall computing power within the cluster. Scalable session state management: Oracle10g allows more users to be hosted on the same or larger hardware platforms due to its new grid mechanism where in new nodes can be added to the cluster when the load increased. Optimized features critical for eBusiness: Oracle10g focuses on the following performance areas, critical for eBusiness: Support for large datafiles. Enterprises planning to setup Data Warehouse and transaction systems can extend their Oracle database upto 8 Exabytes, which is equivalent to 8 million terabytes. Improving the performance of many of today‘s business applications by providing support for enhanced native compilation and improved optimization of PL/SQL. Improving optimization plans and reducing resource usage by adding memory and CPU costs to the cost based optimizer cost calculation algorithm Improving performance in Data Warehouse and Online Transaction Processing (OLTP) environments by general I/O improvements such as better sharing of run-time data structures, larger buffer caches and deferrable constraints. Security Oracle10g provides secure application development and deployment platform by focusing on: A strong three-tier security, which ensures that a user can access the database only through the middle tier. As a result user identities are maintained securely through all tiers of an application, with centralized user and privilege management in Oracle Internet Directory. Deep data protection through enhancements in Virtual Private Database, fine-grained auditing and Oracle Label Security Development Platform for eBusiness Applications Oracle10g continues to provide the best development platform for both eBusiness and traditional application development by focusing on the following key area © SQL Star International Ltd. 43
47.
Enterprise Java Engine: Java support in Oracle10g focuses on improving the performance of the embedded Java Virtual Machine, new JDBC and SQLJ functionalities, and enhancement to Java stored procedures. SQL and PL/SQL improvements: Oracle10g has introduced many enhancements in SQL and PL/SQL to meet modern development requirements. Oracle10g supports inheritance, type evolution, and dynamic method dispatch to increase the usefulness of objects. Along with the existing datatypes, new datatypes have been introduced. It also supports CASE statement, ANSI compliant joins and reserved naming conventions. New Dataypes In addition to the existing datatypes, new datatypes have been introduced. They are BINARY FLOAT and BINARY DOUBLE. Bioinformatics and life science applications have benefited from these datatypes to solve complex computations. Alternative Quote operator: Strings containing single code as literal, can be now be escaped using customized symbols using Q operator. Environmental Scripts after each CONNECT: Previously glogin.sql and login.sql scripts were read at the startup of iSQL*Plus. Now, these scripts are automatically run after each user connects to the database. Multiple Pages Output: Output spanning over multiple pages can now be viewed using NEXT button or can be viewed on a single page as in the previous version. SQLPlus Recycle Bin: SHOW RECYCLEBIN [original_name] command has been introduced to view the dropped database objects. Oracle Flashback Feature: This feature has helped a developer to reduce errors. Oracle Flashback Table: FLASHBACK TABLE statement in SQL allows to recover the accidentally dropped table. PURGE TABLE: This statement removes the database objects permanently from the Recycle Bin. © SQL Star International Ltd. 44
48.
Oracle Flashback Version Query Changes
in the table data can be viewed using VERSION BETWEEN clause. A changed transaction‟s undo records stored in the database must be available. Oracle Flashback Transaction Query Changes made to the tables can be viewed using FLASHBACK_TRANSACTION_QUERY view. This can be helpful for auditing, debugging and even performance analysis. Improved MERGE Functionality MERGE Statement has been improved by making WHEN MATCHED and WHEN NOT MATCHED clauses optional. Also, WHERE clause can now be used in this statement to restrict the values while inserting into target table. Regular Expression functions: Regular Expression functions have been introduced which works beyond the POSIX (Portable Operating System For UNIX) standard for matching ASCII characters. Improvements to PL/SQL: Bulk Binding Enhancements: Performance related to BULK BINDING has been enhanced by introducing INDICES OF and VALUES OF clauses. INDICES OF clause permits sparse data in a collection. VALUES OF clause refers one array values based on another array values. Enhanced Native Compilation: The number of parameters to be set for Native Compilation has been reduced. A much more tight integration of SQL and PL/SQL runtime engines is made possible. New Packages: DBMS_WARNING: Warnings generated during compile time can be dynamically set using DBMS_WARNING package. UTL_MAIL: This is an enhancement to UTL_SMTP package. Using this, E- mails can be sent through a PL/SQL API. UTL_COMPRESS: This package compresses and uncompressed RAW Byte stream of Large Object (LOB) data. DBMS_METADATA: This package extracts the metadata of a database object, which can be obtained either in XML version or DDL. © SQL Star International Ltd. 45
49.
CLOB and NCLOB Implicit Conversions: You no longer need APIs to convert CLOB to NCLOB and vice versa. This release supports their implicit conversion. Oracle10g and the Internet Oracle8i was the first internet-based database in the world. It recognized that Internet provided the safest and efficient access to data to all users spread across the globe. Oracle10g continues the Oracle9i focus on the Internet by providing a series of enhancements targeted at eBusiness environments. To be able to allow commerce on the net, your system needs some important hardware configuration so that it can support the transactions between the database and the Internet. One important step is to identify the kind of machines that you need. Fat client or Thin client There are two kinds of client available, fat client and a thin client. Before debating whether everybody needs a fat client or a thin client, you need to understand what these terms mean. A fat client is a traditional PC system, which if purchased today would have 64MB or more of memory, 6GB or more of disk space, a fast paced processor and/or a CD- ROM drive. A fat client would have all the codes locally within them. A thin client is a personal computer used mainly for functions like e-mail, presentation of information and word processing. It stores no code/programs locally and only accesses them from the database. The reasons for shift from fat clients to thin clients are due to the following limitations: Loss of critical pieces of information if they reside only on a disk drive in the event of a break down The need for upgrading the software every time a new version comes into the market. This raises a lot of questions. Should the release of new versions force the end users to upgrade their software? Whether to assume that end- users have the necessary skills to upgrade their software? Should the support people go out to hundreds of PCs and upgrade them individually? Isn‘t this a waste of their time when these activities are only for someone who uses e-mail? The above complexities of fat client led to the development of a more mature network known as the Network Computing Architecture (NCA) wherein the end user would not be required to deal with issues like loss of data due to virus attacks or deal © SQL Star International Ltd. 46
50.
with upgradations. Trained
professionals would handle these at some central location. Oracle Internet Platform The positioning of Oracle as an Internet solution company is due to the adoption of NCA. This architecture enables the development, deployment and integration of applications within a networked computing environment. Oracle has developed NCA, which is based on the following three separate tiers: A thin client tier, which is the layer responsible for the presentation of the information. It is the desktop PC running a web browser. An application server tier (the middle tier), which is the layer wherein all the application codes are processed. A database server tier, which is the layer where all the data is stored. A Three-tier Architecture The NCA is designed such that the presentation layer is separated from the application layer. The application layer resides on a server separate from the database server and it is assumed that the application server is the fat client. The application server as well as the database server can be moved to a machine with more resources, which could be placed in a central location and be managed by trained professionals thereby keeping the end users away from all the complexities. Based on the above theoretical concepts, Oracle 10g release is broadly divided into: • Oracle Database 10g • Oracle Application Server 10g © SQL Star International Ltd. 47
51.
• Oracle Enterprise
Manager 10g Grid Control • Oracle Database 10g Oracle10g database supports Grid Computing architecture. Here, multiple database servers are pooled together to form a cluster. It enhances utilization of resources. It efficiently stores and manages the structured and unstructured data such as: • Spreadsheets • Word documents • PowerPoint presentations • XML • Multimedia data types like MP3, graphics, video and more. Oracle 10g facilitates two-tiered or multi-layered distributed database environments like client/server and Web-based applications. Large objects need be stored inside and outside the database. Oracle Database 10g has services which help to manage and retrieve data, located outside the database. • Oracle Application Server 10g A complete infrastructural platform is provided for developing and deploying enterprise applications, integrating many functions including a J2EE and Web services run-time environment, an enterprise portal, an enterprise integration broker, business intelligence, Web caching, and identity management services. The existing 9iAS gets further enhanced with the introduction of new grid computing features. It further integrates users, applications and data across your organization. • Oracle Enterprise Manager 10g Grid Control It is the consolidated, core management console that forms the basic framework to automatically initiate administrative tasks across the networked environment. With Oracle Grid Control, multiple hardware nodes, databases, application servers and other targets can be brought together into single logical entities. Oracle10g continues Oracle Corporation’s lead on providing the best platform support for business intelligence by focusing on the challenges raised by large volume of data and the need for real time complex analysis in an eBusiness environment. Oracle10g provides the business intelligence platform by enhancing and extending database support for Online Analytical Processing (OLAP), data mining and extraction. © SQL Star International Ltd. 48
52.
Summary In this chapter,
you have learnt that: In Oracle10g, ‗g‘ stands for GRID. It is a technology, which groups similar resources into a cluster. This allows efficient utilization of resources. This helps us to design complex business applications. Data availability, security and development for e-business applications are some of the advantages with Oracle10g. Oracle10g structure is based on NCA (Networked Computing Architecture), which is developed to overcome the problems with fat client. It enables development of applications within networked computing environment. Oracle10g has come up with new features in SQL* Plus environment, new commands in SQL language and improvements in PL/SQL, making it more user friendly. © SQL Star International Ltd. 49
53.
Chapter 3
Data Retrieval iSQL*Plus Interface Logging into Database using iSQL*Plus Projection, Selection and Join Terminology Differences Between SQL and iSQL*Plus Review of Syntaxes for Basic SQL SELECT statements Arithmetic and Concatenation Operators in SQL statements Alternative Quote Operator Saving SQL Statements to Script Files © SQL Star International Ltd. 50
54.
Objectives At the end
of this chapter, you will be able to: Use the SELECT statement to extract data Understand the various categories of SQL statements © SQL Star International Ltd. 51
55.
Retrieving Data Oracle uses
the Structured Query Language (SQL) to communicate with the database. The SQL statement used to extract data from the database is the SELECT statement. The SELECT statement informs the database about the data you want to retrieve. SQL statements need to be executed in an environment where, they would be interpreted and sent to database. iSQL*Plus Environment iSQL*Plus introduced in Oracle9i is a browser environment in which SQL statements are executed. SQL*Plus environment was the default environment in the prior releases of Oracle. SQL*Plus is still available. Since the Oracle server understands only SQL worded statements, all Oracle tools support SQL syntax. Implementation of SQL through SQL*Plus environment or iSQL*Plus environment meets the ANSI (American National Standard Institute) and ISO (International Standards Organization) standards. On issuing an SQL statement, the statement first gets stored in a part of the memory, which is called the SQL buffer. The SQL statements (stored in the buffer) are then recognized and submitted to the Oracle database for execution by the SQL*Plus or the iSQL*Plus environment. The iSQL*Plus environment helps to perform the following tasks: Executing SQL statements to extract, add, change and remove data from the database Formatting and performing calculations on query results so as to produce more meaningful reports Storing SQL statements in files (called script files) so that they could be used later. These files have .sql file extension. How to log in to SQL*Plus and iSQL*Plus? The steps involved in logging into SQL*Plus and iSQL*Plus environments are different. Logging in to SQL*Plus Environment Logging in to SQL*Plus environment depends on the type of operating system you are working on. © SQL Star International Ltd. 52
56.
Logging in through
a Windows environment: 1.Click Start-> Programs-> Oracle – OraDb10g_home1 2. Select Application Development -> SQL Plus © SQL Star International Ltd. 53
57.
3. Enter username,
password and the connect string. Logging in through a command-line environment: Log on to the DOS prompt Enter SQL*Plus command as follows: sqlplus [username[/password[@ ConnectString]]] Where,username is the database username assigned to each user. password is the password the user enters to gain access to the database. The password is visible on entering it at the command line. Therefore, to ensure the integrity of the password, do not enter it at the command line. Instead enter it at the password prompt. @ ConnectString is the alias through which the user has to access the database. Logging in to iSQL*Plus Environment The steps to log in to iSQL*Plus environment are as follows: 1. Initiate the browser and enter the URL address of the iSQL*Plus environment. iSQL*Plus browser window is displayed. © SQL Star International Ltd. 54
58.
2. Enter the
username and password as shown in the following screen. Click the Login button. © SQL Star International Ltd. 55
59.
After you log
in to iSQL*Plus, you see the iSQL*Plus window as follows: Within the windows browser, the key areas of the iSQL*Plus window are the: Enter Statements field: The area to enter the SQL statements and iSQL*Plus commands. Execute button: Click to execute the statements entered in the Enter Statements field. Load Script button: Click to access the area for entering the name and location of a file (containing the contents of the Enter Statements field, which has been saved) or the URL for the script you want to execute. Save Script button: Click to save the contents of the Enter Statements field to a file. It is suggested that you save these files with .sql extension. Cancel Button: Click to Cancel the query presently entered by the user. A confirmation is displayed at the end. Clear Screen button: Click to clear text from the Enter Statement field, output and stops any script running at that time. Help icon: Click to access iSQL*Plus help documentation. © SQL Star International Ltd. 56
60.
iSQL*Plus Commands iSQL*Plus has
a set of commands, which are different from the SQL statements. These commands need to be entered one line at a time. In order to continue a command on the next line, end the current line with a hyphen (-). iSQL*PLUS commands can be abbreviated. For instance, a command CLEAR BUFFER could be written as CL BUFF. iSQL*Plus commands are not stored in the SQL buffer. The main categories into which iSQL*Plus commands have been divided are: Environment – It affects the behavior of SQL statements for the session. Formatting – It formats the query output. File manipulation – It saves SQL statements into script files and, loads and runs them whenever needed. Execution – It sends SQL statements from the browser to the Oracle server. Editing – It modifies SQL statements in the Edit window. Interaction – It allows you to pass values into the SQL statements and also print messages to the screen. SQL Vs iSQL*Plus SQL is the language used to communicate with the Oracle server from any tool or application. iSQL*Plus is the Oracle tool, which recognizes and submits the SQL statements to the Oracle server for execution, and based on the query result, it produces formatted reports using its own commands. The following diagram depicts the SQL and iSQL*Plus interaction: © SQL Star International Ltd. 57
61.
Browser
SQL Statements iSQL*Plus Oracle Server iSQL*Plus Commands Query Output Formatted Report Features of SQL are: It is a non-procedural language of ANSI standard It is an English-like language Features of iSQL*Plus are: It is accessible from a browser It supports ad hoc entry of statements It formats query output into a basic report It can access local as well as remote databases It controls environmental settings © SQL Star International Ltd. 58
62.
SQL Statements The SQL
statements can be categorized with regard to their functionality. They are: SELECT statements - used to retrieve data from the database. Data Definition Language (DDL)- used to create and maintain the database structure. The DDL statements are: CREATE ALTER DROP RENAME TRUNCATE © SQL Star International Ltd. 59
Baixar agora