Week 4 Lecture Conceptual Data Modeling CSE2132 Database Systems Week 4 Lecture Conceptual Data Modeling Conceptual Data Modeling 4. 1
Aims of Database Design Reduce data redundancy. Provide stable data structures that can be readily changed with changing user requirements. Allow users to make ad hoc requests for data. · Maintain complex relationships between data elements. Support a large variety of decision needs. Hawryszkiewycz I J (1984) Database Analysis and Design p 2 Conceptual Data Modeling 4. 2
Design Criteria - data availability - data reliability - data currency - data consistency - data flexibility - data efficiency Verify these criteria are satisfied via technical review Conceptual Data Modeling 4. 3
Database Design - the process of developing database structures from user requirements for data - a structured methodology Structured Methodology - a number of ordered formal processes with known inputs and expected outputs Objectives 1. derive relationships 2. evolve to meet user requirements 3. user requests are met within reasonable time limits Conceptual Data Modeling 4. 4
Conceptual Design in the System Lifecycle Enterprise Modeling Project Identification and Selection Project Initiation and Planning } Conceptual Data Modeling Analysis Logical Database Design Logical design Physical design Physical Database Design Implementation Database Implementation Maintenance DB Maintenance Conceptual Data Modeling 4. 5
The Entity-Relationship Model Represents major data objects and the relationships between them. Widely used commercially in Australia. Originated by Chen in 1976 and adapted in the 'Information Engineering' approach. An Entity model is composed of textual descriptions of objects and a graphical representation called an Entity Relationship Diagram Conceptual Data Modeling 4. 6
ER Diagram Notation Attribute Entity Multivalued Attribute Weak Entity Derived Attribute Associative Entity Identifying Relationship Relationship Conceptual Data Modeling 4. 7
Entity Relationship Modelling Entities form relationships with one another and each entity may be described by one or more attributes. Customer Places (Placed By) Sale Order ENTITY RELATIONSHIP ATTRIBUTE CUSTOMER Any person or organization who purchases goods Customer Number, Customer Name, Customer Phone Conceptual Data Modeling 4. 8
Entity Type Sometimes referred to as an entity set. A set of objects about which we wish to store information. Smith, Jones, Brown Entity instances i.e members of the set LECTURER LECTURER Entity Type or Entity Set is a classification of similar instances. Conceptual Data Modeling 4. 9
Entity Type In practice Entity Instance is often shortened to 'Instance’ and Entity type is shortened to Entity. Entity names should be brief but unambiguous i.e clearly reflect the meaning . Entities should be named in the singular and are often recognized as nouns or noun phrases. Entities can model any object set of interest i.e physical, conceptual, events etc. Conceptual Data Modeling 4. 10
Entity Type versus Weak Entity Type A strong entity type (i.e. an entity type) exists independently of other entity types. A weak entity type is an entity type whose existence depends on some other entity type. The entity type on which the weak entity type depends is called the identifying owner Emp_ID E_Name D_Name D_O_B EMPLOYEE has DEPENDENT Conceptual Data Modeling 4. 11
Attributes An attribute is a property or characteristic of an entity type that is of interest to the organization. Years_Employed is a derived attribute. Skill is a multi-valued attribute. Address is a composite attribute Street Employee_Name Postcode Employee_ID Address Skill Years_Employed EMPLOYEE Date_Employed Conceptual Data Modeling 4. 12
Attribute Types A data item or element that describes one entity type. STUDENT RESULT Student#, Subject Code, Year, Semester, Grade S1 COT423 1990 1 N S1 COT423 1990 2 HD Primary Key or Identifier Some or all of the attributes describing an entity type which serve to uniquely identify each entity instance. Conceptual Data Modeling 4. 13
Value Sets or Domains Each attribute type describes one entity type and is based on an underlying domain or value set. EMPLOYEE Emp# Emp-Gender Emp-Name Emp-Hire-Date E1 Female Jones 20/6/89 DEPENDENT Emp# Depend-Name Depend-Sex Birthdate E1 Smith Male 23/6/46 Conceptual Data Modeling 4. 14
Relationship A named association between two entity types. Entity type Relationship Type Entity Type CUSTOMER Places (Placed By) SALES ORDER Conceptual Data Modeling 4. 15
Relationship Relationship names should indicate the role or reason for the association in both directions. A relationship may have attributes. CUSTOMER Places (Placed By) SALES ORDER Conceptual Data Modeling 4. 16
Relationship Instances A relationship instance is an association between two entity instances. CUSTOMER SALES ORDER Smith Places Order# 651 Jones Places Order# 375 A relationship type is a classification of relationship instances. Places (Placed By) CUSTOMER SALES ORDER Conceptual Data Modeling 4. 17
Degree of Relationship is paid 1 1 Employee Salary Binary contain 1 m Binary Order Part 1 m is a leader/ member is a leader/ member Employee Employee Unary m n m runs on p Ternary Computer Op. System n Software Conceptual Data Modeling 4. 18
Relationship Cardinality (Maximal Cardinalities) One to One One to Many Many to Many Employee Customer Supplier Leads (Lead by) Supplies (Supplied by) Places (Placed by) Project Sales Order Item Relationships represent the 'Business Rules' of the organisation. Conceptual Data Modeling 4. 19
Relationship Cardinality (Minimal Cardinalities) The entity participation in the relationship may be mandatory or optional. CUSTOMER SALES ORDER Places (Placed By) A Customer may place many Sales Orders. A Sales Order must be placed by one Customer. Conceptual Data Modeling 4. 20
Associative Entity The presence of a relationship with one or more attributes suggests that the relationship should perhaps be represented as an entity. An associative entity is an entity type that associates the instances of one or more entity types and contains attributes that are peculiar to the relationship between those entity instances. COURSE EMPLOYEE completes C_No Date_Completed EMPLOYEE COURSE CERTIFICATE Conceptual Data Modeling 4. 21
Abstractions in Conceptual Database Design Classification abstraction: Class BICYCLE (black bicycle, my bicycle .... ) Aggregation abstraction: Aggregation BICYCLE (wheel, seat, handle bar .. ) Generalization abstraction: Generalization VEHICLE(bicycle, car, truck .. ) VEHICLE GENERALISATION CAR BICYCLE AGGREGATION WHEEL SEAT HANDLEBAR PEDAL CLASSIFICATION STANDARD BAR STRAIGHT BAR RACER BAR Conceptual Data Modeling 4. 22
Synonyms or Aliases Be careful to differentiate between things and their names. ITEM = PART = PRODUCT ??? SYNONYM or ALIAS The same object called different names by different people. This problem concerns entity types, relationship types and attribute types. Conceptual Data Modeling 4. 23
Homonyms Different things called the same name by different people ?? EMPLOYEE START DATE In the Personnel area this may mean the date an employee started with the company. In a given department this may mean the date an employee started with the department. This problem also concerns entity types, relationships types and attribute types. Conceptual Data Modeling 4. 24
Identifying Entity Types Entity type names are generally nouns or noun phrases. Can the entity type be defined in one or two sentences ? What are some typical attributes describing the entity type ?? Which attributes uniquely identify each entity instance ? Conceptual Data Modeling 4. 25
Identify the Entity Types ABC COMPANY SALES ORDER Order # ____________ Order Date __ / __ / __ Customer Name __________________________________ Customer Address________________________________ _________________________________________________ Item# Description Qty-ord Unit-Price Ext-Price ____ _______________ _______ $_______ $_______ Conceptual Data Modeling 4. 26
Building an ER Model List the major entity types in the system and note the relationship types between them. Represent the entity types by named rectangles. Identify relationship types between entity types including relationship degree and nature. Conceptual Data Modeling 4. 27
Entity Type Proforma Entity Name ________________ Aliases___________________ Definition ______________________________________________ Purpose ______________________________________________ Name of Entity Super-type _______________________________________ Sub-type Predicate _______________________________________ Sub-type Class Disjoint / Overlapping Total / Partial Number of Instances ___________________________________________ Inserts per period ______________ Deletes per period ________ Insert, Update & Delete Procedures Conceptual Data Modeling 4. 28
Relationship Definition Entity 1 Name ____________ ____ Entity 2 Name __________________ Relationship Name (E1 to E2) _______________ Aliases _______________ Relationship Name (E2 to E1) _______________ Aliases _______________ Definition, Description & Purpose Degree (E1 to E2) 1:1, 1:m, m:1, m:n Nature (E1 to E2) M:O, O:M, O:O, M:M Referential Integrity Rules Cascade (C), Nullify (N), Restrict (R) E1 to E2 Delete ________ Update ________ E2 to E1 Delete ________ Update ________ Conceptual Data Modeling 4. 29
Attribute Definition Entity Name ___________________________ OK Value Attribute Name Domain Name Primary Foreign Key Nulls Default Validation Rules Key References OK Value Conceptual Data Modeling 4. 30
Domain Definition Domain Name ___________________ Aliases _______________________ Definition ____________________________________________________ Valid Values and Meanings ________________________________________ ________________________________________________________________ Data Type ________ Size ________ Validation Rules Comments Conceptual Data Modeling 4. 31
ER Modelling Exercises For each of the following problems prepare an Entity Relationship diagram. For relationship types you should name the relationship in both directions;indicate the degree i.e. 1:1, 1:m, m:n; and the nature i.e optional or mandatory. Entity types should be defined in one or two sentences and some possible attribute types identified together with the likely primary key of the entity type. You should also attempt to identify some of the domains or value sets on which the attribute types are based. 1. A Company is made up of several Divisions with each Division employing many Salespersons. Salespersons write many Orders with each Order relating to only one Salesperson and one Customer. Many Items may be ordered on an Order and a given Item may appear on many Orders. 2. The Pearcey Centre for Computing runs a number of evening Courses with each course being identified by a four character course code. Each course runs at a certain time on a certain evening. Students may enrol in any number of courses concurrently provided the courses are not running at the same time on the same evening. Conceptual Data Modeling 4. 32
A Possible Answer to 1. 1. A Company is made up of several Divisions with each Division employing many Salespersons. Salespersons write many Orders with each Order relating to only one Salesperson and one Customer. Many Items may be ordered on an Order and a given Item may appear on many Orders. belongs to Company Item (contains many) places Order has Division Salesperson Customer employs Conceptual Data Modeling 4. 33