Download presentation
Presentation is loading. Please wait.
1
Relational Database
2
Dr. Edgar F. (Ted) Codd To fellow pilots and aircrew in the Royal Air Force during World War II and the dons at Oxford: These people were the source of my determination to fight for what I believed was right during the ten or more years in which government, industry, and commerce were strongly opposed to the relational approach to database management.
3
Relational Definitions
Every relation has a unique name. Every attribute value is atomic. Every row is unique. Attributes in tables have unique names. The order of the columns is irrelevant. The order of the rows is irrelevant.
4
Relational Definitions
Tuple Attribute View
5
Relational Keys and Structures
Primary Key Candidate Key Composite Key Foreign Key One-to-Many Relationship Many-to-Many Relationship Intersection Data
6
Relational Concepts Relational Algebra Relational Calculus
Relational Operations SELECT PROJECT JOIN Equijoin - Join field appears twice. Natural Join - Join field appears once.
7
Schema for four relations (Pine Valley Furniture)
8
Instance of a relational schema
9
Integrity Constraints
Domain Constraints Allowable values for an attribute. Entity Integrity No primary key attribute may be null. Operational Constraints Business rules.
10
Referential integrity constraints (Pine Valley Furniture)
11
Integrity Constraints
Referential Integrity For example: Delete Rules Restrict Cascade Set-to-Null
12
Well-Structured Relations
Insertion Anomaly Deletion Anomaly Modification Anomaly
13
Transforming E-R Diagrams into Relations
1. Map Regular Entities to Relations (Fig. 6-8). Composite attributes: Use only their simple, component attributes (Fig. 6-9). Multi-valued Attribute - Becomes a separate relation with a foreign key taken from the superior entity (Fig. 6-10).
14
Mapping a composite attribute
(a) CUSTOMER entity type with composite attribute
15
(b) CUSTOMER relation with address detail
16
Transforming E-R Diagrams Into Relations
2. Map Weak Entities Becomes a separate relation with a foreign key taken from the superior entity (Fig. 6-11).
17
Example of mapping a weak entity
(a) Weak entity DEPENDENT
18
(b) Relations resulting from weak entity
19
Transforming E-R Diagrams Into Relations
3. Map Binary Relationships One-to-Many - Primary key on the one side becomes a foreign key on the many side (Fig. 6-12). Many-to-Many - Create a new relation with the primary keys of the two entities as its primary key (Fig. 6-13). One-to-One - Primary key on the mandatory side becomes a foreign key on the optional side (Fig. 6-14).
20
Example of mapping a 1:M relationship
(a) Relationship between customers and orders
21
(b) Mapping the relationship
22
Example of mapping an M:N relationship
(a) Requests relationship (M:N)
23
(b) Three resulting relations
24
Mapping a binary 1:1 relationship
25
(b) Resulting relations
26
Transforming E-R Diagrams Into Relations
4. Map Associative Entities Identifier Not Assigned Default primary key for the association relation is the primary keys of the two entities (Fig. 6-15). Identifier Assigned It is natural and familiar to end-users. Default identifier may not be unique. (Fig. 6-16).
27
Mapping an associative entity with an identifier
(a) Associative entity (SHIPMENT)
28
(b) Three relations
29
Transforming E-R Diagrams Into Relations
5. Map Unary Relationships One-to-Many - Recursive foreign key in the same relation (Fig. 6-17). Many-to-Many - Bill-of-materials: Two relations: One for the entity type. One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity. (Fig. 6-18).
30
Transforming E-R Diagrams Into Relations
6. Map Ternary (and n-ary) Relationships One relation for each entity and one for the associative entity. (Fig. 6-19).
31
Mapping a ternary relationship
(a) Ternary relationship with associative entity
32
(b) Mapping the ternary relationship
33
Supertype/subtype relationships
34
Mapping Supertype/subtype relationships to relations
35
Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data. The process of decomposing relations with anomalies to produce smaller, well-structured relations.
36
Functional Dependencies and Keys
Functional Dependency: The value of one attribute (the determinant) determines the value of another attribute. Candidate Key: Each non-key field is functionally dependent on every candidate key. Fig
37
Steps in normalization
38
First Normal Form No multi-valued attributes.
Every attribute value is atomic. Fig. 6-2a, b.
39
Second Normal Form 1NF and every non-key attribute is fully functionally dependent on the primary key. Every non-key attribute must be defined by the entire key, not by only part of the key. No partial functional dependencies. Fig. 6-2b, 6-22b.
40
Third Normal Form 2NF and no transitive dependencies (functional dependency between non-key attributes.) Fig. 6-23, 6-24, 6-25.
41
Relation with transitive dependency
(a) SALES relation with simple data
42
(b) Transitive dependency in SALES relation
43
Removing a transitive dependency
(a) Decomposing the SALES relation
44
(b) Relations in 3NF
45
Merging Relations (View Integration)
Synonyms: Different names, same meaning. Homonyms: Same name, different meanings. Transitive Dependencies: e.g. (Stu ID, Major) (Stu ID, Advisor). Supertype/Subtype.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.