80 likes | 253 Views
Principles of Database Design, Part II. AIMS 2710 R. Nakatsu. Entity-Relationship (ER) Modeling. ER Modeling is the process of creating a graphical representation of the structure of the database by defining entities and relations among them.
E N D
Principles ofDatabase Design, Part II AIMS 2710 R. Nakatsu
Entity-Relationship (ER)Modeling ER Modeling is the process of creating a graphical representation of the structure of the database by defining entities and relations among them. • The ER model serves as the basic database blueprint. • The ER model can be used as a communication tool.
ER Model Components • An entity is represented by a rectangle containing the entity’s name. An entity corresponds to a table in the relational environment. • A relationship is an association between entities. They are represented by diamond-shaped symbols. • Cardinality expresses the specific number of entity occurrences associated with the related entity.
Relationships Types of Relationships • One-to-One e.g., one dean to one university one head-of-state to one country • One-to-Many e.g., one painter paints many paintings one customer places many orders • Many-to-Many e.g., students enroll in courses
Cardinality in an ER Diagram Teaches 1 M Professor Class (1,1) (0,3) M N Enrolls Student Class (1,6) (0,N) Note: An N cardinality means that there is no limit.
ER Diagram Problem • Acme Insurance Company is made up of several divisions. A claims adjuster is always assigned to one and only one division. • Claims adjusters work on several insurance claims. Each insurance claim is always worked on by a team of at least two but no more than five claims adjusters. Draw the ER Diagram for this situation. Note: a claims adjuster is an employee who investigates and processes insurance claims.
Linking Tables: 1:M and 1:1 In a one-to-one and one-to-many link, you link a primary key in one table to a foreign key in another table. For a one-to-one relationship, the foreign key must be unique. In Access you set the Index value to Yes (No Duplicates). Referential Integrity: A condition in which a child table’s foreign key must have either a null entry or a matching entry in the related parent table.
Linking Tables: Many-to-Many • For many-to-many relationships, you must create a separate intersection table to handle the relationship. • Access will not let you define a many-to-many relationship directly between two tables. • The primary key of the intersection is a composite primary key. • Two one-to-many relationships are created. Students Enroll Courses