Lecture 07
Lecture 07
• Data Modeling
• Understanding User Needs & Extract Business Rules
• Conceptual Data Model
Data modeling is the process of creating a data model for the data to be stored in a
Database:
Emphasize on what data is needed and how it should be store.
Visualize representation of data and enforces business rules, compliances and
policies on the data.
Ensure the consistency in naming conventions, default values, semantics, security
while ensuring quality of the data.
▪ Ensure that all data objects required by the database are accurately represented
▪ Help to design the database in conceptual, logical and physical levels
▪ Help to present the relations between tables
▪ Provide a clear picture about the DB that helps Developer create physical DB
▪ Help to identify missing and redundant data
▪ Help IT to upgrade and maintain DB faster and cheaper
Until now we know why the database design is so important but how we can design
a good database ?
Data Modeling
For example:
▪ If a student doesn’t enroll in at least one class, change the Status field
to Inactive.
▪ If an order totals more than $50 before taxes and shipping, give free
shipping.
▪ Don’t make a Customer record until the customer buys something and
has an associated order.
For example:
You only ship orders to states where you have a warehouse and those
include Colorado, Kansas & Nebraska. A business rule requires that the
State field in an order’s shipping address must be CO, KS or NE.
If a rule is likely to change frequently, it’s probably worth some extra planning
to make changing the rule easier.
Some types of rules that make good candidates for extra attention
▪ Create a customer record when the customer places his/her first order.
▪ Give 20% discount if a female customer placed orders in national woman’s days.
▪ All customer records must include phone numbers.
▪ Give a 10% discount if the customer pays in full in advance.
1. Identify the rules that are simple or that seem unlikely to change so they can be
built into the database.
2. Identify the rules that may change or that are complicated enough to pay attention.
Now that you’ve identified the business rules that will be tricky to implement
within the database or that may change frequently, pull them out of the
database.
Data Modeling
Make a purchase
Lead Customer
Entity Attribute
symbols symbols
Relationship
symbols
Symbol : Rectangle
SHOULD BE:
▪ An object that will have many instances in the database
▪ An object that will be composed of multiple attributes
▪ An object that we are trying to the model
Please define an entity type STUDENT and also list two entity instances of it.
Hint: You should list which attributes an entity type STUDENT must have
Classification of attributes:
▪ Simple vs Composite Attribute
▪ Single-valued vs Multi-valued Attribute
▪ Stored vs Derived Attributes
▪ Identifier Attributes
Composite Attribute
Simple Attributes
© 2021 Datapot Analytics. All rights reserved. 31
Attributes (cont.)
Multi-valued Attribute
Payroll_
Employee_Name
Address Date_ Years_
Employee_ID Skill
Employed employed
First Last Street Zip Multi-valued
001 Jacky TAN
Hill Street
100
164607 May 01, 1999 C/C++/Java 19 attributes
Stamford
002 Susan LIM Road 80
178902 Oct 14, 2000 Java/.Net 18
The entity type STUDENT has the following attributes: Id (unique), Name,
Phone, Age, Activity, and No_of_Year
Activity: represents some campus-based student activity
No_of_Year: the number of years the student may have engaged
in this activity
An assumption: a given student may engage in more than one activity.
When the attributes depend on all the entities that participate in the relationship
(but not a single entity), the attributes belong to the relationship.
Degree of a relationship
▪ Number of entities participating in the relationship
Cardinality of relationship
▪ Number of instances of one entity that can or must be associated with each
instances of another entity
Unary Ternary
Binary
Binary Relationship between STUDENT Entity type and COURSE Entity type
STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address
It includes:
▪ One – to – One: each entity in the relationship will have exactly one related
entity.
▪ One – to – Many: an entity on one side of the relationship can have many
related entities, but an entity on the other side will have a maximum of one
related entity
▪ Many – to – Many: entities on both sides of the relationship can have many
related entities on the other side
STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address
Cardinality Constraints - the number of instances of one entity that can or must be
associated with each instance of another entity.
Maximum Cardinality
Minimum Cardinality
© 2021 Datapot Analytics. All rights reserved. 50
Example
STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address
A student can register for zero or many courses
STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address