Chapter 4 High-level Database Models Entity/Relationship Models (E/R diagram) Unified Modeling Language (UML) Object Definition Language (ODL) Hot to Transfer them to a relational model 1
1 Chapter 4 High-level Database Models Entity/Relationship Models (E/R diagram) Unified Modeling Language (UML) Object Definition Language (ODL) Hot to Transfer them to a relational model
Introduction ▣现实世界:客观存在的世界。 ▣信息世界:现实世界在人们头脑中的反映。 ▣机器世界:信息世界的信息在机器世界中以数据的形 式存放。 reality-》information world-》machine world E-R data model relational model√ UML object-relational model ODL object-oriented model 2
2 Introduction 现实世界:客观存在的世界。 信息世界:现实世界在人们头脑中的反映。 机器世界:信息世界的信息在机器世界中以数据的形 式存放。 reality - 》information world- 》 machine world E-R data model relational model √ UML object-relational model ODL object-oriented model
Purpose of E/R Model The E/R model allows us to sketch database schema designs. Includes some constraints,but not operations. Designs are pictures called entity- relationship diagrams. Later:convert E/R designs to relational DB designs. 3
3 Purpose of E/R Model The E/R model allows us to sketch database schema designs. Includes some constraints, but not operations. Designs are pictures called entityrelationship diagrams. Later: convert E/R designs to relational DB designs
Framework for E/R Design is a serious business. The "boss"knows they want a database,but they don't know what they want in it. Sketching the key components is an efficient way to develop a working database
4 Framework for E/R Design is a serious business. The “boss ” knows they want a database, but they don ’t know what they want in it. Sketching the key components is an efficient way to develop a working database
Entity/Relationship Model Entity like objects,=things Entity set like class set of similar Entity or objects Attribute=property of entities in an entity set,similar to fields of a struct. Relation=connect two or more entity set In diagrams, entity set rectangle; attribute:oval, relation:diamonds 5
5 Entity/Relationship Model Entity like objects, =things Entity set like class = set of similar Entity or objects Attribute=property of entities in an entity set, similar to fields of a struct. Relation=connect two or more entity set In diagrams, entity set : rectangle; attribute: oval, relation: diamonds
Entity/Relationship Diagrams: example ID name address Students taking Course No.)( name teacher 6
6 Entity/Relationship Diagrams: example Students ID name address Course taking No. name teacher
Relationships Binary (relation between two entity sets) Multiway (relation between more than two entity sets) Multiplicity of relationships:Express the number of entities to which another entity can be associated via a relationship set. 7
7 Relationships Binary (relation between two entity sets) Multiway (relation between more than two entity sets) Multiplicity of relationships: Express the number of entities to which another entity can be associated via a relationship set
Binary Multiway Relationships ID name address Students TA Students 卡nros taking Course Course Assisting TA No.)( name teacher 8
8 Binary & Multiway Relationships Students ID name address Course taking No. name teacher TA Assisting Course Students TA Enrolls
Beers-Bars-Drinkers Example name )address license bars <Serves Frequents Beers Likes Drinkers name (manf name addr 9
9 Beers-Bars-Drinkers Example bars Beers Drinkers Serves Likes Frequents name address license name manf name addr
Example:3-Way Bar Dr inker Beer Relationship Joe's Bar Ann Miller Sue's Bar Ann Bud Sue's Bar Ann Pete's Ale Joe's Bar Bob Bud name addr Joe's Bar Bob Miller Joe's Bar Cal Miller Sue's Bar Cal Bud Lite license Bars name Suppose that drinkers will Beers only drink certain beers manf at certain bars. Preferences Our three binary relationships Likes, Sells,and Frequents name do not allow us to make this distinction. Drinkers But a 3-way addr 10 relationship would
10 Example: 3-Way Relationship Bars Beers Drinkers name name addr manf name addr license Preferences Suppose that drinkers will only drink certain beers at certain bars. Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction. But a 3-way relationship would