Академический Документы
Профессиональный Документы
Культура Документы
Objectives
Ver. 1.0
Session 2
Slide 1 of 16
Reflects entities and their relationships, based on the data processing needs of an organization Can be mapped to a relational, hierarchical, or network model Is independent of individual applications, database management systems, hardware, and physical storage of data
Ver. 1.0
Session 2
Slide 2 of 16
A database that conforms to an ER diagram can be represented by a collection of tables in the relational system. The mapping of ER diagrams to tables can be discussed in relation to the following:
Regular entities Attributes Relationships Weak entities Subtypes and Supertypes
Ver. 1.0
Session 2
Slide 3 of 16
They can exist in isolation, independent of any other entity. They are the building blocks of the database. Each regular entity maps to a table.
Ver. 1.0
Session 2
Slide 4 of 16
Each property or attribute shown in the ER diagram maps to a column in the appropriate table.
Ver. 1.0
Session 2
Slide 5 of 16
Each type of relationship maps to tables in a different manner in the relational database management system. The most important principle is to create tables where information from the real world is stored and retrieved in an optimal way; that is, a minimum number of tables with a minimum number of attributes. In a relational system, a join operation retrieves all information by combining two or more tables. Are of the following types:
One-to-One One-to-Many Many-to-Many
Ver. 1.0
Session 2
Slide 6 of 16
A weak entity is an entity whose existence depends on some other entity. It cannot exist if the entity on which it depends does not exist.
Ver. 1.0
Session 2
Slide 7 of 16
Each entity type (subtypes and supertypes) maps to a separate table. The primary key of the supertype is the foreign key of the subtype:
It creates a link between the two. The foreign key of the subtype is also its primary key.
Ver. 1.0
Session 2
Slide 8 of 16
Keys:
Relational systems require keys that uniquely identify the rows of a table. There are various types of keys:
Primary Foreign Candidate Alternate Composite
Ver. 1.0
Session 2
Slide 9 of 16
Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key. Such an attribute is called a candidate key. Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key. Keys can be simple or composite:
A simple key is composed of a single attribute. A composite key, on the other hand, comprises two or more attributes.
Ver. 1.0
Session 2
Slide 10 of 16
Answer:
1. Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key. Such an attribute is called a candidate key. 2. Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key.
Ver. 1.0
Session 2
Slide 11 of 16
Entities:
Some attributes may acquire further attributes during database design and become entities.
Subentities:
Replace optional attributes of an entity with subentities. This is called specialization. Specialization is the result of taking a subset of a higher-level entity set to form a lower-level entity set. Generalization is the result of taking the union of two or more lower-level entity sets to produce a higher-level entity set.
Ver. 1.0
Session 2
Slide 12 of 16
Problem Statement
Map the ER diagram to its corresponding tables.
Ver. 1.0
Session 2
Slide 13 of 16
Ver. 1.0
Session 2
Slide 14 of 16
In one-to-one relationships, one instance of an entity can relate to only one instance of the related entity. In a one-to-many relationship, one instance of an entity can relate to more than one instance of the related entity. Many-to-many relationships map to tables. One-to-one relationships are not very common and may map to foreign keys in tables. A weak entity is an entity whose existence depends on some other entity. A subtype is a subset of another entity. A subtype is always dependent on supertype for its existence. The primary key of the supertype is the foreign key of the subtype. It creates a link between the two.
Ver. 1.0
Session 2
Slide 15 of 16
A candidate key is a candidate for the primary key. An alternate key is a candidate key that is not a primary key. Optional attributes should be replaced with subentities; this is also called specialization. To simplify multiple references, a new superentity should be introduced; this is also called generalization.
Ver. 1.0
Session 2
Slide 16 of 16