
Database The Entity Relationship Model Management Peter Wood Overview Entities Attributes Relationships I An example of a conceptual (high-level) data model Weak Entity Types I Useful for design before moving to a lower level ISA relationships model (e.g. relational) I Alternatives include I UML (Unified Modelling Language) and I ODL (Object Description Language) Database Modelling Steps Management Peter Wood S Overview S ¡ Entities aspects of SS ¡ Attributes ¡ the real world ¡ ¡ Relationships h¡ hh ((¡ hhh((( Weak Entity Types ISA relationships manual modeling ? conceptual schema (ER schema) Z Z Z semi-automatic Z transformation Z Z = ? ZZ~ relational network object oriented schema schema schema I Integrity constraints I primary keys for entity types and relationship types, and I multiplicity (cardinality) constraints for relationship types I The ER model is only a partial data model, since it has no standard manipulative part Database The Components of the ER Model Management Peter Wood Overview Entities I Structural part Attributes I entity types Relationships I attributes Weak Entity Types I relationship types ISA relationships I The ER model is only a partial data model, since it has no standard manipulative part Database The Components of the ER Model Management Peter Wood Overview Entities I Structural part Attributes I entity types Relationships I attributes Weak Entity Types I relationship types ISA relationships I Integrity constraints I primary keys for entity types and relationship types, and I multiplicity (cardinality) constraints for relationship types Database The Components of the ER Model Management Peter Wood Overview Entities I Structural part Attributes I entity types Relationships I attributes Weak Entity Types I relationship types ISA relationships I Integrity constraints I primary keys for entity types and relationship types, and I multiplicity (cardinality) constraints for relationship types I The ER model is only a partial data model, since it has no standard manipulative part Database The Main Advantages of the ER Model Management Peter Wood Overview Entities Attributes Relationships The diagrams (ERDs) associated with entity-relationship Weak Entity Types models ISA relationships I are relatively simple I are user-friendly I can provide a unified view of data, which is independent of any implemented data model Database The Building Blocks of an ERD Management Peter Wood Overview Entities and entity types (entity sets) I Entities I Relationships and relationship types Attributes I Attributes, keys and roles Relationships Weak Entity Types ISA relationships Database Entities and Entity Types Management Peter Wood Overview An entity is a “thing” that exists and can be uniquely Entities Attributes identified, e.g., an individual person. Relationships Weak Entity Types An entity type (or entity set) is a collection of similar ISA relationships entities, e.g., a collection of people. An entity type I is similar to a class in object-oriented languages I has associated attributes, which represent properties of the entities comprising the entity type I is represented in an ERD by a rectangle Database Attributes Management Peter Wood Overview Entities Attribute names (or simply attributes) are properties of Attributes entity types. Relationships Weak Entity Types ISA relationships I Each attribute usually has only simple values (e.g. integers or character strings) I represented by an oval in an ERD, with a line to the rectangle representing its entity type I Sometimes multi-valued attributes (e.g. Phones) are allowed I represented by a double oval in an ERD Database Example of Entity Type and Attributes Management Peter Wood Overview Entities Attributes Name Address Relationships Weak Entity Types ISA relationships NI# Person Phones I Each Person has a single Name, Address and National Insurance number (NI#) I Each Person can have many Phones Database Domain Management Peter Wood Overview Entities Attributes The domain of an attribute of an entity type is the set of Relationships constant values associated with that attribute. Weak Entity Types ISA relationships Domains can be I atomic such as the domain of integers or the domain of strings, or I set-valued such as the domain of finite sets of integers or of finite sets of strings. Database Relationship Types Management A relationship type is an association between two or more Peter Wood entity types. Overview Entities Attributes Relationship types are represented in an ERD by I Relationships diamond shapes, Weak Entity Types I with lines to each of the rectangles representing ISA relationships entity types involved in the association Example of a relationship type Teaches between entity type Lecturer and entity type Student: Lecturer Teaches Student Database Relationships Management A relationship is an instance of a relationship type, i.e., it Peter Wood is the set of associations between the entities comprising Overview the entity types associated by the relationship type. Entities Attributes Relationships Weak Entity Types ISA relationships I Above diagram is not an ERD I Entities for one entity type on left (green) I Entities for another entity type on right (red) I Lines between entities show the relationship Database Multiplicity Constraints in Relationship Types Management Peter Wood Overview Entities Attributes I many-to-one (or one-to-many) Relationships An Employee Works in one Department or a Weak Entity Types Department has many Employees. ISA relationships I one-to-one A Manager Heads one Department and vice versa. I many-to-many A Lecturer Teaches many Students and a Student is Taught by many Lecturers. Database Example of many-to-one relationship type Management Peter Wood Overview Entities Attributes Relationships Employee Works-in Department Weak Entity Types ISA relationships The arrowhead is drawn at the “one” end of the relationship type I Each Employee Works-in one Department I Each Department has many Employees working in it Database Example of many-to-one relationship Management Peter Wood Overview Entities Attributes Relationships Weak Entity Types ISA relationships Database Example of one-to-one relationship type Management Peter Wood Overview Entities Attributes Relationships Weak Entity Types Manager Occupies Office ISA relationships The arrowhead is drawn at both ends of the relationship type I Each Manager Occupies one Office I Each Office has one Manager occupying it Database Example of one-to-one relationship Management Peter Wood Overview Entities Attributes Relationships Weak Entity Types ISA relationships Database Example of many-to-many relationship type Management Peter Wood Overview Entities Attributes Relationships Weak Entity Types Lecturer Teaches Student ISA relationships No arrowheads are drawn I Each Lecturer Teaches many Students I Each Student is taught by many Lecturers Database Example of many-to-many relationship Management Peter Wood Overview Entities Attributes Relationships Weak Entity Types ISA relationships Database Multiple relationship types Management There may be more than one relationship type between Peter Wood two entity types. Overview Entities Attributes Relationships Teaches Weak Entity Types ISA relationships Lecturer Student Tutors I Teaches relationship type is many-to-many I Tutors relationship type is one-to-many (from Lecturer to Student) Database Participation Constraints in Relationships Management Peter Wood Overview I optional relationship Entities I e.g., an Employee may or may not be assigned to a Attributes Department Relationships I Participation of entity (e.g., Employee) in relationship Weak Entity Types is said to be partial ISA relationships I This is the default for relationships in our notation I (Sometimes indicated by cardinality constraint of 0..*) I mandatory relationship I e.g., every Course must be Taught by at least one Lecturer I Participation of entity (e.g., Course) in relationship said to be total I Indicated by double lines in our notation I (Sometimes indicated by cardinality constraint of 1..*) Database Example of Participation Constraints Management Peter Wood Overview Entities Lecturer Teaches Student Attributes Relationships Weak Entity Types ISA relationships I Some Lecturers may not Teach any Students I Each Student must be taught by at least one Lecturer 0..* 1..* Lecturer Teaches Student Database Binary Versus Multiway Relationship Types Management Peter Wood Overview Entities Attributes Supplier Supplies Part Relationships Weak Entity Types ISA relationships Project I each supplier may supply different parts to different projects I Supplies is an example of a ternary relationship type Database Keys and Superkeys Management Peter Wood Definition of a superkey. A set of attributes of an entity Overview type is a superkey if for each entity, say e, over that type, Entities the set of values of the attributes in the superkey uniquely Attributes identifies e. Relationships e.g., a Person may be uniquely identified by {Name, NI#} Weak Entity Types ISA relationships Definition of a key. A key for an entity type is a superkey which is minimal. e.g., to uniquely identify a Person, NI# is sufficient I simple keys are single attribute keys, such as Emp# and NI#. I composite keys are keys having more than one attribute, such as {Department, University} and {Name, Address}. Database Management Definition of primary key of an entity type. A primary Peter Wood key is a key that has been designated as such by the database designer. Overview Entities Attributes I The primary
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages38 Page
-
File Size-