Presentation is loading. Please wait.

Presentation is loading. Please wait.

Db design / ER Modeling 20031 319B Database Systems ER-Modeling Part 2 Wilhelm Steinbuss Room G2.04, ext 4052

Similar presentations


Presentation on theme: "Db design / ER Modeling 20031 319B Database Systems ER-Modeling Part 2 Wilhelm Steinbuss Room G2.04, ext 4052"— Presentation transcript:

1 db design / ER Modeling 20031 319B Database Systems ER-Modeling Part 2 Wilhelm Steinbuss Room G2.04, ext 4052 steinbus@cs.waikato.ac.nz

2 db design / ER Modeling 20032 3. Relationship(types) Relationship- and Rolenames Cardinalities Mandatory / optional Reflexive relationship types N-ary realtionship types Gerund XOR relationship types

3 db design / ER Modeling 20033 Relationship types A relationship type is an assoziation between several (not necessary different) entity types (and so it is an associative entity type because it describes a fact referencing more than one entititype) If these associative entity type does not own additional attributes the rectangle and the arrows are dropped (except for n-ary relations)

4 db design / ER Modeling 20034 Example Instead of We can use

5 db design / ER Modeling 20035 3.1 Relationship- and Rolenames A relationship can be named and the involved entities could have an assigned role Example:

6 db design / ER Modeling 20036 3.2 Cardinalities Cardinality ist the number of entities (instances of an entity type) with which one entity could be connected Example: a person can have several addresses; an address is assigned to exactly one person personaddress

7 db design / ER Modeling 20037 3.3 Reflexive relationship type Relation between entities of the same type Example:

8 db design / ER Modeling 20038 Reflexive relationship (Cont.) A person can be married more than once over time:

9 db design / ER Modeling 20039 3.3 Mandatory / optional Lay down whether a relation must be or is optional Example: - a person have not to own an account, but can own more than one - an account must be owned by at least one person, but can be owned by many persons

10 db design / ER Modeling 200310 Example Zoo There are a lot of animal species in the zoo. Every animal species can be placed within exactly one enclosure type (aquarium, cage, outdoor enclosure). For each enclosure type exists possibly more than one enclosure with different amount of space (or volume). In one enclosure there is at most one animal species Each animal needs a minimum of space allocated (e.g. 12 m², 0.1 m³). The number of actual allocated animals in an enclosure should be recorded Every animal species is attended by at exactly one conservator Add additional requirements if necessary.

11 db design / ER Modeling 200311 Solution Additional requirements: - In an enclosure type different animal species can be placed - An enclosure is of exactly one type - An animal species can be placed in more than one enclosure - perhaps an enclosure is empty - perhaps an animal species is not placed into an enclosure

12 db design / ER Modeling 200312 Exercise bicycle manufacturer The bicycle manufacturer produces more than one bicycle type A bicycle consists of more than one assembly An assembly contains several parts (or other assemblies) Parts can be supplied by several suppliers For an order a recording have to be done including the number of ordered parts

13 db design / ER Modeling 200313 3.5 n-ary Relationship types A relationship which has more than two entities involved Example:

14 db design / ER Modeling 200314 3.6 Gerund A gerund is an associative entity which is treated like a fundamental entity Example:

15 db design / ER Modeling 200315 Example consultancy A consultancy realizes projects with their customers A customer can have more than one project Each project is leaded by exactly one consultant For each month the number of hours which an employee has worked for a project are recorded These records are the base for the invoice An invoice must have at least a relation to one of the records

16 db design / ER Modeling 200316 Solution consultancy

17 db design / ER Modeling 200317 Exercise Library A book in a library is published by a publishing company For each book type exists at least one book instance A book must have assigned at least one or more author(s) There can be keywords for every book For each person who borrows books an address is necessary An user of the library can borrow books or make an advance booking There is a fee (sliding scaled) per day for every overdraft (e.g. $1 for each day in the first week, $2 for each day in the second etc.) An overdraft can cause (one or more) overdue notification(s) An overdue notification can be related to more than one overdraft For every overdue notification there is a fee (depending on the previous number of notifications; e.g $1.50 for the first, $2 for the second and so on)

18 db design / ER Modeling 200318 3.7 XOR Relationship types Exactly one of the relationships which are marked with the XOR construct is valid Example: (ex. 5)


Download ppt "Db design / ER Modeling 20031 319B Database Systems ER-Modeling Part 2 Wilhelm Steinbuss Room G2.04, ext 4052"

Similar presentations


Ads by Google