
Simplified phases of Database Design Mini World (Extended) Entity Relationship Modelling Requirements collection & analysis and Database requirements Mappings to the Relational Data Model Conceptual design DBMS Independent Conceptual schema (in a high level data model) Data model design Conceptual schema (in the data model of a specific DBMS DBMS specific Physical design Internal schema (for the same DBMS) Data Definition Language Statements Conceptual Data Model Concepts Conceptual Data Model Concepts “There exist things which have certain properties and which may be related in some Attribute way(s) to other things. Data represents fact about an Entity Type or Relationship Type specific facts about the things” an entity is often expressed as a set of attributes Entity thing or object that exists in its own right and is Entity Set or Extent distinguishable, represented by an Entity Type of which there will be many Entity Instances…... Set of all Entity Instances of the same Entity Type physical objects, events, activities, associations Relationship Relationship Set or Extent an association between several entities Set of all Relationship Instances of the same represented by a Relationship Type of which there Relationship Type will be many Relationship Instances Entity Types and Relationship Types Optional Relationship Types Staff Works_for Department Staff Manages Department ST1 r1 ST1 r1 D1 D1 ST2 ST2 r2 ST3 D2 ST3 D2 r3 D3 r2 D3 ST4 ST4 r4 r3 ST5 ST5 …. …. ST6 r5 ST6 …. r6 …. …. …. Many:many Relationship Types Recursive Relationship Types Course Staff Teaches Staff r1 Manages ST1 r1 ST1 1 C1 ST2 unmanaged ST2 1 r2 2 ST3 C2 ST3 r2 r3 C3 2 ST4 ST4 2 r3 C4 r4 1 ST5 2 …. r4 …. r5 2 ST6 r5 1 …. r6 …. …. 1 1. Manager 2. Employee Entity Relationship Model Attributes in Conceptual Modelling given family 1 For each and every attribute must define domain, SCHOOL REG studno name data type, format and whether it can be null m hons STUDENT faculty m Every entity type must have a key attribute or set n m YEARREG year of attributes 1 labmark YEAR Composite or Atomic ENROL TUTOR 1 exammark Single-valued or Multi-valued slot YEARTUTOR Derived given courseno 1 family courseno m 1 Null valued no. of m n labmark equip TEACH name students COURSE name STAFF m m n subject roomno 1 STUDENT ENROL COURSE equip appraisee appraiser exammark studno subject APPRAISAL Properties of Relationship Types Semantic Data Models Degree Extended-Entity-Relationship Modelling The number of participating entity types Cardinality ratios Entity Attribute Relationship Modelling The number of instances of each of the Entity Relationship Attribute Modelling participating entity types which can partake in a Entity Modelling single instance of the relationship type 1:1, 1:many, many:1, many:many Object Modelling Participation (optionality) IFO, The relationship instance doesn’t have to exist NIAM etc.… Whether an entity instance has to participate in a Extensions for temporal, constraints, rules etc relationship instance Role Chen 1976 The function that a particular entity type plays in a relationship type Entity Relationship Modelling Roles & Recursive Relationships Composite Keys The function of an entity type in a name relationship type PERSON STAFF dateofbirth name m roomno 1 appraisee appraiser APPRAISAL Roles & Association Relationships Non-binary Relationship The function of an entity type in a roomno STAFF relationship type name STAFF p given family courseno given family equip name TUTORS m n name name COURSE STUDENT SUPERVISE slot 1 m subject studno STAFF STUDENT 1 m EXAMINER roomno studno Entity Relationship Model Mapping Entity Types to Relations For every entity type create a relation given family 1 SCHOOL name REG { primary_key (E) U {a1…am} } studno STUDENT m hons Every attribute in entity becomes a relation attribute STUDENT faculty (studno, givenname, m familyname, hons, n m The relation is a subset of the X of the domains of the YEARREG year tutor, slot, year) attributes 1 ENROL(studno, courseno, Composite attributes—just include all the atomic attributes labmark YEAR labmark,exammark) ENROL TUTOR Derived attributes are not included but their derivation 1 exammark slot COURSE(courseno, subject, equip) rules are YEARTUTOR STAFF(lecturer, roomno, appraiser) given family courseno m 1 1 courseno m n TEACH(courseno, lecturer) no. of TEACH labmark equip COURSE name STAFF name students YEAR(year, yeartutor) subject 1 m m ENROL n roomno STUDENT COURSE equip appraisee appraiser SCHOOL(hons, faculty) exammark studno subject APPRAISAL Mapping many:many Relationship Types to Mapping one:many Relationship Types to Relations Relations Mostly: ‘Posting the primary key’ Create a relation: Given E1 at ‘many’ end of relationship and E2 at ‘one’ end of relationship, add to the relation for E1 n (degree of relationship) Make the primary key of the entity at the ‘one’ end (the determined U primary_key(E ) U {a …a } entity) a foreign key in the entity at the ‘many’ end (the determining i 1 m entity). Include any relationship attributes with the foreign key entity i=1 primary keys of each attributes on the { E1 U primary_key(E2) U {a1…an} } participating entity relationship type (if any) type in the relationship attributes on relation for primary key for E2, is given family courseno entity E1 the relationship no. of now a foreign key to E2 labmark equip type (if any) name students m given family ENROL n name STUDENT COURSE slot roomno name exammark m studno subject TUTOR 1 studno STUDENT STAFF Mapping one:many Relationship Types to Mapping one:many Relationship Types to Relations Relations Sometimes... If relationship type is optional to both entity types and an instance of the relationship is rare, and there are lots of STUDENT STAFF attributes on the relationship then… studno given family tutor slot name roomno Create a relation for the relationship type: s1 fred jones bush 12B kahn IT206 s2 mary brown kahn 12B bush 2.26 {primary_key(E1) U primary_key(E2) U {a1…am} s3 sue smith goble 10A goble 2.82 s4 fred bloggs goble 11A zobel 2.34 s5 peter jones zobel 13B watson IT212 primary key for E1, is now a primary key for attributes on the s6 jill peters kahn 12A woods IT204 foreign key to E1; E2, is now a relationship type capon A14 also the PK for this relation foreign key to E2 (if any) lindsey 2.10 barringer 2.125 given family name slot roomno name m TUTOR 1 studno STUDENT STAFF Mapping one:many Relationship Types to Relations Optional Participation of Determined Entity (‘one end’) STUDENT studno given family A school entity instance s1 fred jones A student entity instance STAFF does not have to s2 mary brown must participate in a name roomno participate in a relationship s3 sue smith relationship instance of REG kahn IT206 instance of REG s4 fred bloggs bush 2.26 s5 peter jones goble 2.82 given family s6 jill peters 1 zobel 2.34 SCHOOL name REG watson IT212 studno TUTOR m hons studno tutor slot woods IT204 STUDENT faculty s1 bush 12B capon A14 s2 kahn 12B lindsey 2.10 barringer 2.125 s3 goble 10A SCHOOL(hons,faculty) s4 goble 11A s5 zobel 13B STUDENT(studno,givenname,familyname, ??? ) s6 kahn 12A Optional Participation of Determined Entity Optional Participation of the Determinant STUDENT Entity (‘many end’) studno given family hons s1 fred jones ca hons can’t be null s2 mary brown cis because it is mandatory s3 sue smith cs given s4 fred bloggs ca for a student to be family name slot roomno s5 peter jones cs registered for a school. name m s6 jill peters ca TUTOR 1 studno STUDENT STAFF SCHOOL hons faculty ca accountancy no-one registered for mi A student entity instance A staff entity instance cis information systems so doesn’t occur as a does not have to must participate in a cs computer science participate in a relationship relationship instance of ce computer science foreign key value instance of TUTOR TUTOR mi medicine cm mathematics Optional Participation of the Determinant Entity (‘many end’) Optional Participation of the Determinant Entity 1. STUDENT (studno,givenname,familyname,tutor,slot) STAFF(name, roomno) STUDENT STAFF Integrity constraints: studno given family tutor slot name roomno π STAFF – π STUDENT = ∅ s1 fred jones bush 12B kahn IT206 (name) (tutor) s2 mary brown kahn 12B bush 2.26 s3 sue smith goble 10A goble 2.82 s4 fred bloggs null null zobel 2.34 s5 peter jones zobel 13B 2. STUDENT(studno,givenname,familyname) watson IT212 s6 jill peters null null STAFF(name,roomno) woods IT204 capon A14 TUTOR(studno,tutor,slot) lindsey 2.10 barringer 2.125 3. same as 2 if lots of attributes on TUTOR Mapping one:one Relationship Types to Relations Multi-Valued Attributes 1. Post the primary key of one of the entity types Create a relation for each multi-valued attribute into the other entity type as a foreign key, { primary_key(Ei) U multi-valued attribute } including any relationship attributes with it or The primary key is (primary_key(Ei) U multi-valued attribute) 2.Merge the entity types together STUDENT studno given family dateofbirth contact STAFF year s1 fred jones 10/4/78 Mr. Jones name roomno 1 Mrs Jones kahn IT206 YEAR s2 mary brown 12/1/72 Bill Brown given family bush 2.26 Mrs Jones 1 dateofbirth goble 2.82 YEAR name Billy-Jo Woods YEARTUTOR zobel 2.34 year yeartutor studno STUDENT STUDENT_CONTACTS watson IT212 1 zobel studno contact name roomno woods IT204 2 bush 1 s1 Mr. Jones contact s1 Mrs Jones capon A14 3 capon STAFF s2 Bill Brown lindsey 2.10 s2 Mrs Jones barringer 2.125 s2 Billy-Jo Woods Mapping Roles & Recursive Relationships Multiple Roles between Entity Types 1.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages10 Page
-
File Size-