Step 1: Create and Check ER Model Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept of Computer Engineering Khon Kaen University Overview The tasks in Step 1 of the database design methodology, which build an ER model. The documentation produced during Step 1 of database design, including Entity Relationship (ER) diagrams and a data dictionary. 2 Step 1 Create and Check ER Model Objective is to build an ER model of the data requirements of an organization (or part of an organization) to be supported by a database 3 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1
Step 1 Tasks (1/2) Step 1.1 Identify entities Step 1.2 Identify relationships Step 1.3 Identify and associate attributes with entities or relationships Step 1.4 Determine attribute domains Step 1.5 Determine candidate, primary, and alternate key attributes 4 Step 1 Tasks (2/2) Step 1.6 Specialize/Generalize entities (optional step) Step 1.7 Check model for redundancy Step 1.8 Check model supports user transactions Step 1.9 Check model with users 5 Step 1.1 Identify entities One method is to examine the users requirements specification for nouns or noun phases Look for major objects such as people, places, or concepts of interest Excluding those nouns that are merely qualities of other objects Document entities 6 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 2
StayHome entities Branch Video Member Actor Staff VideoForRent RentalAgreement Director 7 Extract from data dictionary for StayHome 8 Step 1.2 Identify relationships One method is to examine users requirements specification for verbs or verbal expressions Use entity relationship (ER) modeling Determine the multiplicity constraints of relationships Check for fan and chasm traps Document relationships 9 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 3
First ER diagram of StayHome 10 First draft of relationships for StayHome 11 Multiplicity constraints for relationships 12 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 4
Adding multiplicity constraints to ER diagram 13 Extract from the data dictionary showing descriptions of relationships 14 Step 1.3 Identify and associate attributes with entities or relationships Attributes can be identified where noun or noun phrase is a property, quality, identifier, or characteristic of one of the entities or relationships previously found. Document attributes 15 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 5
Documenting attributes (1/2) Attribute name and description Data type and length Any aliases that the attribute is known by Whether the attribute must always be specified (in other words, whether the attribute allows or disallows nulls) 16 Documenting attributes (2/2) Whether the attribute is multi-valued; Whether the attribute is composite, and if so, which simple attributes make up the composite attribute; Whether the attribute is derived and, if so, how it should be computed; Default values for the attribute (if specified) 17 Associate attributes with entities Branch (branchno, address(composite street, city state, zipcode), telno (multi-valued)) Staff (staffno, name, position, salary) Video (catalogno, title, category, dailyrental, price) Director (directorname) Actor (actorname) Member (memberno, name (composite: fname, lname), address) RentalAgreement (rentalno, dateout, datereturn) VideoForRent (videono, available) 18 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 6
Extraction of data dictionary showing descriptions of attributes 19 Step 1.4 Determine attribute domains A domain is a pool of values from which one or more attributes draw their values A domain specifies: allowable set of values for the attribute; size and format of the attribute. Document attribute domains 20 Step 1.5 Determine candidate, primary, and alternate key attributes Identify candidate key(s) for an entity and then selecting one to be the primary key Candidate keys can never be null Remaining candidate keys are called alternate keys Document candidate, primary and alternate keys 21 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 7
Guidelines for choosing a primary key (1/2) Select the candidate key The minimal set of attributes That is less likely to have its values changed That is less likely to lose uniqueness in the future 22 Guidelines for choosing a primary key (2/2) Select the candidate key With fewest characters (for those with textual attribute(s)) With the smallest maximum value 9for numerical attributes) That is easiest to use from the users point of view 23 ER diagram showing primary keys 24 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 8
Extract from data dictionary showing attributes with primary and alternate keys 25 Step 1.6 Specialize/Generalize entities (optional step) Objective is to identify superclass and subclass entities, where appropriate The modeling of superclasses and subclasses adds more information to the data model, but also adds more complexity as well 26 Step 1.7 Check model for redundancy Examine the ER model and if redundancy found, remove from model The three activities in this step are (1) re-examine one-to-one (1:1) relationships (2) remove redundant relationships (3) consider the time dimension when accessing redundancy 27 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 9
Remove redundant relationships 28 Non-redundant relationships 29 Step 1.8 Check model supports user transactions ER model represents the data requirements of the organization Objective is to check that ER model supports the required transactions. Two possible approaches: (1) Describing the transaction (2) Using transaction pathways 30 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 10
Using pathways to check ER model supports user transactions 31 Step 1.9 Check model with users Objective is to review the ER model with the user to ensure that the model is a true representation of the data requirements of the organization (or the part of the organization) to be supported by the database 32 Summary Step 1: Create and Check ER Model Identify entities, relationships, attributes Identify primary and alternate key attributes Specialize/Generalize entities (optional step) Check model for redundancy Check model supports user transactions Check model with users 33 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 11
References Connolly and Begg, Database Systems: A Practical Approach to Design, Implementation and Management, Pearson, 2004 34 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 12