Data Modeling - I: Business Information Systems
Data Modeling - I: Business Information Systems
Data Modeling - I
DATA MODEL
The specification of data structures and business rules to represent business requirements.
STUDENT
student id student last name student first name student major
COURSE
course id
attends/ is taught to
Entities
ENTITY
A person, place, thing, event, or concept about which the business keeps data.
Identify why the business needs this information Improve understanding Avoid redundancy
Unique entity names in a model A non-technical, business-like name A singular noun that describes a singular instance (no collective nouns)
ORDER
LINE ITEM
Attributes
ATTRIBUTE
A distinct characteristic of an ENTITY for which data is maintained.
Attribute Names :
ENTITY Name (above the box)
EMPLOYEE
employee id employee employee employee employee first name last name address phone number
attributes
Attribute Types
Two types of attributes:
Key Non-key
CONSULTANT
consultant id consultant first name consultant last name consultant specialization consultant hourly rate
CANDIDATE KEY
Any attribute or group of attributes which serves to uniquely identify each instance of an ENTITY.
BOOK
author first name author last name book title book edition book publisher book year published book isbn book lc catalog number
BOOK
author first name author last name book title book edition book publisher book year published book isbn book lc catalog number
BOOK
author first name author last name book title book edition book publisher book year published book isbn book lc catalog number
Primary Keys
PRIMARY KEY An ATTRIBUTE or group of attributes that uniquely identifies an instance of the entity.
BOOK
book isbn
author first name author last name book title book edition book publisher book year published book lc catalog number
Factors to consider:
Should be efficient Must not contain any null parts Values must remain static Should be a data element in your control
Surrogate Keys
SURROGATE KEY
A contrived, non-intelligent, single-attribute key used to replace a long composite key.
Composite Key
Surrogate Key
10
the primary key is created as a composite of 2 or more non key attributes or a single but new and artificial attribute called surrogate key is created
11
Relationships
RELATIONSHIP A logical link between two entities that represents a business rule or constraint.
MOVIE
is rented as
MOVIE COPY
12
Relationships
1:1 One to one mandatory; One student has one address 1:N One to many mandatory ; A customer having multiple addresses 1:1 One to one optional; An employee may or may not have a spouse 1:N One to many optional; One order having many order items M:N many to many; Many parts being supplied by many suppliers
PART
is ordered from/sends us
SUPPLIER
13
Relationship Cardinality
places
CUSTOMER
ORDER
A customer places zero, one, or more orders. An order relates to only one customer. STUDENT
has
BOOK
Each student has one or more books. A book is with one student
is ticketed for
AIRPLANE SEAT
PASSENGER
Each seat will seat zero or one passenger. One passenger can sit on only one seat.
CAR
Each car has exactly N tyres
requires N
TYRE
14
Creating ER Diagram
Identify and list all the entities of the system For each entity list the attributes Identify the candidate keys and choose the primary key based on the application For each pair of entities, decide if there is a relationship If there is a relationship, decide what kind Use tools like Visio to draw the ER Diagram Discuss the ER model with end users (walkthrough)
15
Relationship Rules
1:1 mandatory; this means that both are parts of larger entity; One entity is merged with the other to create an entity which has attributes of both entities 1: 1 optional; primary key of one entity is placed as attribute of the entity which is optional 1:n optional/ mandatory; primary key of singular entity is placed as an additional attribute in the entity that can have multi occurrences N:M; create new artificial entity which has primary key of both original entities as attributes
16
OMS
Product
N M
Order
N M
Customer
Product
Order
N M
Customer
Order Item
Note: For clarity in understanding the type of relationship, the relationship names are not metioned in this diagram
17
Foreign Keys
A primary key of a parent entity that is contributed to a child entity across a relationship.
ORDER
order number order date order sales representative order customer
contains
LINE ITEM order number (FK) line item sequence number product code line item quantity line item number line item description
Inserting, updating, or deleting a Parent Primary Key value? Inserting, updating, or deleting a Child Foreign Key value?
None of these actions should break the relationship from Child to Parent Options can be specified as to how the DBMS should manage these actions to maintain referential integrity 18
Exercise
Identify the entity, attributes and the key
ORDER
Order Date Customer Name Customer Address Customer Credit Rating Order Value Item 1 Desc Item 1 unit price Item 1 quantity Item 1 Deliver Date Item 2 Desc Item 2 unit price Item 2 quantity Item 2 Deliver Date
Apply the ER diagram rules for the data model of a library system Supplier
N M
Parts
N M
Product
Next Class
Data Normalization