Download presentation
Presentation is loading. Please wait.
Published byRobert Mills Modified over 9 years ago
1
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications C. Faloutsos E-R diagrams
2
Carnegie Mellon 15-415 - C. Faloutsos2 Overview concepts –Entities –Relationships –Attributes –Specialization/Generalization –Aggregation turning E-R diagrams to tables
3
Carnegie Mellon 15-415 - C. Faloutsos3 Tools Entities (‘entity sets’) Relationships (‘rel. sets’) and mapping constraints attributes NM P
4
Carnegie Mellon 15-415 - C. Faloutsos4 Example Students, taking courses, offered by instructors; a course may have multiple sections; one instructor per course nouns -> entity sets verbs -> relationships
5
Carnegie Mellon 15-415 - C. Faloutsos5 STUDENT name ssn... INSTRUCTOR issn
6
Carnegie Mellon 15-415 - C. Faloutsos6 STUDENT name ssn... COURSE c-id c-name but: sections of course (with different instructors)? INSTRUCTOR issn
7
Carnegie Mellon 15-415 - C. Faloutsos7 COURSE c-id INSTRUCTOR issn STUDENT ssn SECTION s-id but: s-id is not unique...
8
Carnegie Mellon 15-415 - C. Faloutsos8 COURSE c-id INSTRUCTOR issn STUDENT ssn SECTION s-id takes N M
9
Carnegie Mellon 15-415 - C. Faloutsos9 COURSE c-id INSTRUCTOR STUDENT SECTION s-id takes N M N 1 teaches
10
Carnegie Mellon 15-415 - C. Faloutsos10 Cardinalities 1 to 1 (example?) 1 to N N to M
11
Carnegie Mellon 15-415 - C. Faloutsos11 COURSE c-id INSTRUCTOR STUDENT SECTION s-id takes N M N 1 teaches has N 1
12
Carnegie Mellon 15-415 - C. Faloutsos12 More details ‘weak’ entities: if they need to borrow a unique id from a ‘strong entity - DOUBLE box. ‘c-id’ + ‘s-id’: unique id for SECTION discriminator (eg., ‘s-id’) COURSE c-id SECTION s-idhas N 1
13
Carnegie Mellon 15-415 - C. Faloutsos13 More details self-relationships - example?
14
Carnegie Mellon 15-415 - C. Faloutsos14 EMPLOYEE manages 1 N
15
Carnegie Mellon 15-415 - C. Faloutsos15 More details 3-way and k-way relationships? EMPLOYEE uses PROJECT TOOL N M P
16
Carnegie Mellon 15-415 - C. Faloutsos16 More details - attributes candidate key (eg., ssn; employee#) primary key (a cand. key, chosen by DBA) superkey (eg., (ssn, address) ) multivalued or set-valued attributes (eg., ‘dependents’ for EMPLOYEE) derived attributes (eg., 15% tip)
17
Carnegie Mellon 15-415 - C. Faloutsos17 More details: in the text: (eg., ‘total participation’) INSTRUCTOR SECTION 0:N 1:1 teaches
18
Carnegie Mellon 15-415 - C. Faloutsos18 Overview concepts –Entities –Relationships –Attributes –Specialization/Generalization –Aggregation turning E-R diagrams to tables
19
Carnegie Mellon 15-415 - C. Faloutsos19 Specialization eg., students: part time (#credit- hours) and full time (major) STUDENT name ssn PT-STUDENT #credits FT-STUDENT major IS-A
20
Carnegie Mellon 15-415 - C. Faloutsos20 Observations Generalization: exact reverse of ‘specialization’ attribute inheritance could have many levels of an IS-A hierarchy
21
Carnegie Mellon 15-415 - C. Faloutsos21 Aggregation CPU HD treat a relationship as an entity rarely used N M MAKER
22
Carnegie Mellon 15-415 - C. Faloutsos22 Overview concepts –Entities –Relationships –Attributes –Specialization/Generalization –Aggregation turning E-R diagrams to tables
23
Carnegie Mellon 15-415 - C. Faloutsos23 COURSE c-id INSTRUCTOR STUDENT SECTION s-id takes N M N 1 teaches has N 1 grade
24
Carnegie Mellon 15-415 - C. Faloutsos24 Strong entities just list the attributes, and underline the primary key, eg. STUDENT(ssn, name, address)
25
Carnegie Mellon 15-415 - C. Faloutsos25 Multivalued attributes Eg., EMPLOYEE with many dependents: a new table, with (ssn, dependent-name)
26
Carnegie Mellon 15-415 - C. Faloutsos26 Relationships get primary keys all involved entities primary key - depends on cardinality –1 to 1: either eg EMPLOYEE( ssn, empno, name,...) –1 to N: the key of the ‘N’ part eg. TEACHES( issn, c-id, s-id) –N to M: both keys - eg TAKES( ssn, c-id, s-id, grade)
27
Carnegie Mellon 15-415 - C. Faloutsos27 Relationships 1 to N: no need for separate table - eg., SECTION( issn, room-num, c-id, s-id) instead of SECTION1(c-id, s-id, room-num) TEACHES(issn, c-id, s-id) for rel. between strong and corresponding weak entity, no need for table, at all!
28
Carnegie Mellon 15-415 - C. Faloutsos28 Generalization/Spec. Two solutions: - one table for each or - no table for super-entity (pros and cons?)
29
Carnegie Mellon 15-415 - C. Faloutsos29 Generalization/Special. Eg., STUDENT(ssn, name, address) PT-STUDENT( FT-STUDENT(
30
Carnegie Mellon 15-415 - C. Faloutsos30 Generalization/Special. Eg., STUDENT(ssn, name, address) PT-STUDENT( ssn, num-credits) FT-STUDENT( ssn, major)
31
Carnegie Mellon 15-415 - C. Faloutsos31 Generalization/Special. no super-entity: [STUDENT(ssn, name, address)] PT-STUDENT( ssn, num-credits FT-STUDENT( ssn, major
32
Carnegie Mellon 15-415 - C. Faloutsos32 Generalization/Special. no super-entity: [STUDENT(ssn, name, address)] PT-STUDENT( ssn, num-credits, name, address) FT-STUDENT( ssn, major, name, address)
33
Carnegie Mellon 15-415 - C. Faloutsos33 Aggregation make table, with primary keys of all involved entities
34
Carnegie Mellon 15-415 - C. Faloutsos34 Overview concepts –Entities –Relationships –Attributes –Specialization/Generalization –Aggregation turning E-R diagrams to tables
35
Carnegie Mellon 15-415 - C. Faloutsos35 Summary E-R Diagrams: a powerful, user-friendly tool for data modeling: –Entities (strong, weak) –Attributes (primary keys, discriminators, derived, multivalued) –Relationships (1:1, 1:N, N:M; multi-way) –Generalization/Specialization; Aggregation
36
Carnegie Mellon 15-415 - C. Faloutsos36 Summary - cont’d (strong) entity set weak entity set relationship set identifying rel. set for weak entity attribute multivalued attribute derived attribute
37
Carnegie Mellon 15-415 - C. Faloutsos37 Summary - cont’d primary key A discriminator A cardinalities N M with limits l:h l’:h’ IS-A total generalization (e.t.c. - see book for alternative notations)
38
Carnegie Mellon 15-415 - C. Faloutsos38 Conclusions E-R Diagrams: a powerful, user-friendly tool for data modeling.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.