Chapter 2: Oracle PLSQL
Chapter 2: Oracle PLSQL
Teaching Aid
Page 22 - 28
A relational database is based on the concept that the related data is organized and stored in a series of two dimensional tables known as relations A row is called a tuple
A column is called as attribute A primary key is an attribute that determines all the other attributes within that row Each data item in a row is functionally dependent on the primary key
Teaching Aid
Page 22 - 28
PRIMARY KEY A primary key is a minimal combination of field(s) that uniquely identifies the corresponding values of other field in a table. The field(s) of a primary key is known as prime attribute(s). The values of prime attributes can never be NULL FOREIGN KEY A foreign key is an attribute or set of attributes that appears in one table but is the primary key in other table. It is used to link two tables
Teaching Aid
Page 22 - 28
SUPER KEY A super key is combination of prime attribute(s) and one or more nonprime key attribute(s). It also uniquely identifies a record in a table. Primary key can be defined as super key with minimal attributes CANDIDATE KEY & ALTERNATE KEY Candidate key may be two or more keys that uniquely identifies record in a table. Any one in the candidate key can be chosen as a primary key. The remaining keys are called alternate key
Teaching Aid
Page 22 - 28
SETS AND DOMAINS A domain is finite or infinite set from which values can be chosen CARTESIAN PRODUCT For two domains D1 and D2, the Cartesian product, denoted by D1 x D2 is defined as the set of all ordered pairs such that the first element is a member of D1 and second element is a member of D2 RELATIONS A Relation is defined as any subset of the Cartesian product of the domains
Teaching Aid
Page 28 - 32
Two relation P and Q are said to be Union, Intersection and Difference compatible if both P and Q are of same degree n and the domain of the corresponding n attributes are identical UNION Selects the all tuples from the two relations without repetition INTERSECTION Selects the common tuples from the two relations DIFFERENCE Removes common tuples from the first relation
Teaching Aid
Teaching Aid
Page 28 - 32
Teaching Aid
Page 28 - 32
Teaching Aid
Teaching Aid
Page 33 - 45
Normalization is the process of refining the data model built by the Entity-Relationship diagram. The decomposition of more complex data structures into flat files (relation) is known as normalization. A relation is said to be normalized if every value in the relation is atomic.
Teaching Aid
Page 33 - 45
All relations in a relational database are required to be normalized to permit the simple retrieval and maintenance of data through updates, insertions and deletions. It also allows representing any pertinent relationship between entities. Normalization ensures minimum redundancies of data and removes anomalies for database activities.
Teaching Aid
UN-NORMALIZED FORM
3 of 9
Teaching Aid
Page 33 - 45
Teaching Aid
Page 33 - 45
SECOND NORMAL FORM 1 NF and every non-key attribute is functionally dependent on the primary key
Teaching Aid
Page 33 - 45
SECOND NORMAL FORM Elimination of anomalies encountered in First Normal Form Anomalies associated with Second Normal Form
Teaching Aid
Page 33 - 45
Teaching Aid
Page 33 - 45
Teaching Aid
Page 33 - 45
BOYCE - CODD NORMAL FORM If and only if every determinant is a candidate key FOURTH NORMAL FORM BCNF and has no nontrivial multi-values Dependencies FIFTH NORMAL FORM Fourth normal form and every join dependency in the table is a consequence of the candidate key of the table
Teaching Aid
Page 46 - 48
Q1. What are the disadvantages of flat file database? Q2. How Cartesian product and relations are associated with each other? Q3. What is the difference between primary key and unique key? Q4. Define candidate key.
Q5. Define division operation. Q6. Describe fully functional dependency with the help of an example. Q7. Define BCNF and Fourth normal form. Q8. Mention common type of anomalies during normalization process.
Teaching Aid
Page 46 - 48
Q10. If every non-key attribute is functionally dependent on the primary key, the relation will be in a. 1 NF b. 2 NF c. 3 NF d. 4 NF Q11. The column of a table is referred to as the a. Tuple b. Entity c. Degree d. Attribute
Teaching Aid
Page 46 - 48
Q12.Relation produced from an ER model will always be in a. 1 NF b. 2 NF c. 3 NF d. 4 NF Q13. Select True/ False statement a. An alternate key is a primary key that is not a candidate key b. An alternate key is a candidate key that is not a primary key c. An alternate key is a candidate key that is also a primary key Q14. An attribute of one table matching the primary key of another table, is called as a. Primary key b. Unique key c. Composite key d. Foreign key
Teaching Aid
Page 46 - 48
Q15. Oracle database server supports a. Client/ Server architecture b. Three-tier architecture c. None of the above Q16. Join correctly a. Projection b. Selection c. Join the following a. Yields a horizontal subset of a relation b. Selects a vertical subset of a relation c. Allows combining two relations
Q17. A domain is/are a. Finite set from which values can be chosen b. Infinite set from which values can be chosen c. None of the above
Teaching Aid
Page 46 - 48
Q18. Primary key can also be defined as a. Super key with minimal attributes b. Any one candidate key c. Combination of prime attributes d. Alternate key Q19. Disadvantage of normalization is/are a. Elimination of anomalies b. Increase in execution time because of join c. Overall reduction of space d. Minimal redundancy Q20. Transitive dependency is related to a. 1NF b. 2NF c. 3NF d. 4NF
Teaching Aid
Teaching Aid