Professional Documents
Culture Documents
. Department has name, number, manager Manager is an employee Manager has starting date Department has several locations 3. Department controls projects Project has name, number, location 4. Employee has name, social security, number, address, salary, sex, birthdate. 5. Employee is in one department but may work on several projects 6. Hours each employee works on each project 7. Employee has supervisor 8. Employee has dependents with name, sex, birthdate, and relationship to employee.
multivalued (DEGREES) Derived attribute: AGE from BIRTHDATE Attributes may have NULL values unknown not applicable
ENTITY TYPES
An entity type is the set of entities having the same attributes We can describe an entity type by an entity type schema The real entities in the entity type are entity instances entity type <-> entity instances object type <-> object instances relation <-> tuples (relation instances) intension <-> extension
The domain of v1 is {1,4,5} The domain of v2 is {A,B} CARTESIAN PRODUCT {1,4,5} X {A,B} {1,A},{1,B},{4,A},{4,B},{5,A},{5,B} The CAR entity type. Multivalued attributes are shown between braces {}. Components of a composite attribute are shown between ():
First we identify the entity types DEPARTMENT PROJECT EMPLOYEE DEPENDENT Then we identify the attributes for each entity type Multivalued attributes, composite attributes, derived attributes, attributes with possible nulls Key attributes are identified or assumed. For example, we assume each project has a unique project_number Question: Why do we need key attributes? Are there real life objects without key attributes?
PARTICIPATION CONSTRAINT
An employee MUST work for a department An employee entity can exist only if it participates in a WORKS_FOR relationship instance Thus its participation is TOTAL Only some employees manage departments The participation is PARTIAL A formal constraint: (min,max) where m, n are min and max number of times an entity participates in a relationship instance. For example, (0,10) means partial participation, and (1,max) means total participation.
The recursive relationship SUPERVISION - EMPLOYEE plays two roles of "supervisor" and "supervisee":
The 1:1 relationship MANAGES, with partical participation of EMPLOYEE and total participation of DEPARTMENT:
Note: {} indicates multivalued attributes, and () indicates component attributes of a composite attribute
WORKS_FOR (1:N) DEPARTMENT total EMPLOYEE total CONTROLS (1:N) PROJECT total DEPARTMENT partial SUPERVISION (1:N) EMPLOYEE partial EMPLOYEE partial WORKS_ON (M:N) EMPLOYEE total PROJECT total Attribute: Hours DEPENDENTS_OF (1:N) EMPLOYEE partial DEPENDENT total (Weak Entity Type)
The ER Diagram
ER diagram is a graphical design tool ER schema diagram for the COMPANY database:
ER diaram for the COMPANY schema with all role names included and with structural constraints on relationships specified using the (min,max) notation:
An example of ER diagram for the library is shown below, where a key icon indicates the relationship is linked to the key attribute, and a ring icon indicates the relationship is linked to an
OFFERED_DURING: relates a semester to the courses offered during that semester by ANY instructor (s,c) OFFERS: relates an instrcutor who offers a course during a semester (i,c,s) Constraint: (i,c,s) cannot exist unless (i,c),(i,s),(s,c) exist, but converse is not true. The following figures illustrate (a) ternary relationship type SUPPLY; (b) three binary relationship types are not equivalent to one ternary relationship type SUPPLY; (c) another example of ternary versus binary relationship type:
A library is planning to develop a library information system. This library will serve only registered students. Each book has title, author, publisher, date-of-publication, ISBN number and a set of keywords. Each student has SSN, first name, last name, address, telephone number. A student can borrow a book for up to two weeks, so it is necessary to keep track of the date-ofborrow. He can then renew the book for another two weeks. Two renewals are allowed. After two renews, the student must return a borrowed book. If a book is overdue, the student must pay a fine of $0.5 a day.