Presentation is loading. Please wait.

Presentation is loading. Please wait.

3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.

Similar presentations


Presentation on theme: "3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other."— Presentation transcript:

1 3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other attributes Primary key (PK) is an attribute (or a combination of attributes) that uniquely identifies any given row –Composite key - Composed of more than one attribute Foreign key (FK) –An attribute whose values match primary key values in the related table Key’s role is based on determination –If you know the value of attribute A, you can look up (determine) the value of attribute B

2 3 & 4 2 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys (continued)

3 3 & 4 3 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys (continued)

4 3 & 4 4 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Types of Attributes Key attribute is a unique identifier Composite attribute can be subdivided Simple attribute cannot be subdivided Single-value attribute can have only a single value Multivalued attributes can have many values –A student may have more that one phone number; a home- phone number and a mobile-phone number Derived attribute’s value may be calculated (derived) from other attributes –Need not be physically stored in a database

5 3 & 4 5 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel EMPLOYEE is assigned to PROJECT M N Cardinality Connectivity

6 3 & 4 6 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Participation Optional participation –One entity occurrence does not require corresponding entity occurrence in particular relationship Mandatory participation –One entity occurrence requires corresponding entity occurrence in particular relationship

7 3 & 4 7 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Strength Weak (non-identifying) relationships –Exists if PK of related entity does not contain PK component of parent entity Strong (Identifying) Relationships –Exists when PK of related entity contains PK component of parent entity

8 3 & 4 8 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Weak (Non-Identifying) Relationships

9 3 & 4 9 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Strong (Identifying) Relationships

10 3 & 4 10 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Weak Entities Weak entity meets two conditions –Existence-dependent Cannot exist without entity with which it has a relationship –Has primary key that is partially or totally derived from parent entity in relationship Database designer usually determines whether an entity can be described as weak based on business rules

11 3 & 4 11 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Weak Entities (continued)

12 3 & 4 12 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Degree Indicates number of entities or participants associated with a relationship Unary relationship –Association is maintained within single entity Binary relationship –Two entities are associated Ternary relationship –Three entities are associated

13 3 & 4 13 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel EMPLOYEE is assigned to PROJECT is married to PERSON STUDENT student/teacher/subject relationship SUBJECT TEACHER Unary Binary Ternary

14 3 & 4 14 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Degree (continued)

15 3 & 4 15 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel A little about unary relationships Relationship between the rows of a single table is mother to PERSON ID YearofBirth NameMotherID

16 3 & 4 16 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Source: http://io.uwinnipeg.ca/~rmcfadye/2914/ERD/images/1entit4.gif Mandatory participation 1, N, M

17 3 & 4 17 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Suggested Approach 1.Identify entities 2.Identify their attributes Determine key(s) Identify any composite multivalued derived 3.Identify relationships 4.Determine cardinality (1:1, 1:M, M:N) 5.Determine relationship participation mandatory optional 6.Determine weak entities (if any) Can the entity be identified using only its own attributes? If not, then it is a weak entity Weak entity’s key is underlined with a dashed line Weak entities participate in identifying relationships

18 3 & 4 18 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Practice... A database needs to be designed for the university student accommodation services. Each hall of residence has a number (unique), name (unique), address (street, city), phone, and the total number of rooms. Every hall contains single rooms only. Each room has a number (unique within a hall), and a weekly rent 28

19 3 & 4 19 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Practice... You are to design a database for a small library. The database needs to store data about various books the library holds. For each book, the database should record the book id (unique), title, publisher and the year of publication. A book may have several authors, and each author is represented by his/her name. A book typically has several copies. Each copy of a book is given a copy number. The availability of a book copy should be known, as well as the total number of copies. 24

20 3 & 4 20 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Practice … Design a database for a company. For each employee we store his/her name, tax number, address, salary, gender and birthdate. Some employees are supervised, and in those cases we keep track of the supervisee and supervisor. We want to keep track of the dependents of employees for insurance purposes. We keep each dependent's name, gender, birthdate and relationship to the employee who supports the dependent. 33


Download ppt "3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other."

Similar presentations


Ads by Google