0% found this document useful (0 votes)
7 views55 pages

Lecture 07

The document provides an overview of database design, focusing on data modeling, understanding user needs, and extracting business rules. It emphasizes the importance of creating a conceptual data model to ensure clarity and communication between IT and business teams. Key concepts include entity-relationship modeling, cardinality, and the classification of attributes.

Uploaded by

k60.2112280025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views55 pages

Lecture 07

The document provides an overview of database design, focusing on data modeling, understanding user needs, and extracting business rules. It emphasizes the importance of creating a conceptual data model to ensure clarity and communication between IT and business teams. Key concepts include entity-relationship modeling, cardinality, and the classification of attributes.

Uploaded by

k60.2112280025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Data Science for Economics and Business

DATABASE MANAGEMENT SYSTEM

© 2021 Datapot Analytics. All rights reserved.


Database Design

Lecture 07: Database Design Process


Hoang To, MCT

© 2021 Datapot Analytics. All rights reserved.


Lecture Agenda

• Data Modeling
• Understanding User Needs & Extract Business Rules
• Conceptual Data Model

© 2021 Datapot Analytics. All rights reserved.


Database Design

Section 1: Data Modeling

© 2021 Datapot Analytics. All rights reserved.


Data Modeling

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.

© 2021 Datapot Analytics. All rights reserved. 5


Data Modeling

Why use Data modeling?

▪ 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

© 2021 Datapot Analytics. All rights reserved. 6


Three levels of Data Modeling

© 2021 Datapot Analytics. All rights reserved. 7


How to design a good database

Until now we know why the database design is so important but how we can design
a good database ?

1. Understanding User Needs - Extracting business rules


2. Translating user needs into Data models.

© 2021 Datapot Analytics. All rights reserved. 8


Process to design a good database

Extract Business Conceptual Logical Data Physical Data


Rules Data Model Model Model

Data Modeling

© 2021 Datapot Analytics. All rights reserved. 9


Process to design a good database

© 2021 Datapot Analytics. All rights reserved. 10


Database Design

Section 2: Understanding User Needs &


Extract Business Rules

© 2021 Datapot Analytics. All rights reserved.


What is business rules ?

Business rules describe the objects, relationships and actions that a


business find important and worth writing down.

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.

From a database point of view, business rules are constraints.

© 2021 Datapot Analytics. All rights reserved. 12


Identifying Key Business Rules
How you implement a business rule depends not only on how tricky it is to
build, but also on how likely it will be to change later.

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.

Identify key business rules and extract them.


© 2021 Datapot Analytics. All rights reserved. 13
Identifying Key Business Rules

Ask yourself two questions:

- How easy is it to change a rule?


- How likely is the rule to change?

If a rule is likely to change frequently, it’s probably worth some extra planning
to make changing the rule easier.

© 2021 Datapot Analytics. All rights reserved. 14


Types of rules

Some types of rules that make good candidates for extra attention

- Enumerated values: For example, allowed shipping states.


- Calculation parameters: For example, suppose you give free shipping on
orders over $50. Will you later change that to $70 ? $100
- Validity parameters: For example, suppose full-time student must take
between 8-16 credits. Will we ever make this 12 to 16 credits ?

© 2021 Datapot Analytics. All rights reserved. 15


Exercises

Consider this list of business rules:

▪ 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.

© 2021 Datapot Analytics. All rights reserved. 16


Extracting Key Business Rules

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.

There are a couple of standard approaches:


▪ If the rule is a validation list, convert it into a foreign key constraint.
▪ If the rule is a calculation with parameters that may change, pull the
parameters out and put them in a table.
▪ If a calculation is complicated, extract it into code; maybe a programming
language or even stored procedures.

© 2021 Datapot Analytics. All rights reserved. 17


Database Design – Data Modeling

Section 3 : Conceptual Data Model

© 2021 Datapot Analytics. All rights reserved.


Process to design a good database

Extract Conceptual Logical Data Physical Data


Business Rules Data Model Model Model

Data Modeling

© 2021 Datapot Analytics. All rights reserved. 19


Why ?

▪ Conceptual model focuses on the business, is communication method


between IT team and biz team

▪ Through biz rule and definitions of entities presented in Data Glossary,


conceptual model ensure parties to understand about the same things,
avoid misunderstanding reports

© 2021 Datapot Analytics. All rights reserved. 20


Why ?

Examples for biz definitions:


o Customer is a person or an organization who has bought at least one of
our products
o Lead is a person or an organization who doesn’t own any products of our
company but who is potentially interested in purchasing one or more our
products.

Make a purchase
Lead Customer

© 2021 Datapot Analytics. All rights reserved. 21


Entity-Relationship Model

▪ Entity – Relationship model (E-R model) : a logical representation of the


data for an organization or for a business area

▪ Entity – Relationship diagram (E-R diagram): a graphical representation


of an entity-relationship model

© 2021 Datapot Analytics. All rights reserved. 22


Sample E-R Diagram

© 2021 Datapot Analytics. All rights reserved. 23


An Example of an E-R Diagram

© 2021 Datapot Analytics. All rights reserved.


E-R Notation

Entity Attribute
symbols symbols

Relationship
symbols

© 2021 Datapot Analytics. All rights reserved. 25


What is an Entity ?

Entity : a person, place, object, event or concept in the user environment


about which the organization wishes to maintain data. Example:
▪ Person: employee, student, patient,…
▪ Place: store, warehouse, …
▪ Object: machine, automobile, …

Entity type: 3 types Strong, Weak, Associative

Symbol : Rectangle

© 2021 Datapot Analytics. All rights reserved. 26


What is an Entity ?

Entity type Two instances


© 2021 Datapot Analytics. All rights reserved. 27
What should an Entity be ?

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

SHOULD NOT BE:


▪ An output of the database system (e.g. a report)
▪ A user of the database system

© 2021 Datapot Analytics. All rights reserved. 28


Exercise

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

© 2021 Datapot Analytics. All rights reserved. 29


Attributes

Attributes – property or characteristic of an entity type.

Classification of attributes:
▪ Simple vs Composite Attribute
▪ Single-valued vs Multi-valued Attribute
▪ Stored vs Derived Attributes
▪ Identifier Attributes

Symbol: Attribute names inside the entity rectangle

© 2021 Datapot Analytics. All rights reserved. 30


Attributes (cont.)

Simple and Composite Attribute

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

© 2021 Datapot Analytics. All rights reserved. 32


Attributes (cont.)
Identifiers : an attribute (or combination of attributes) that uniquely identifies
individual instances of an entity type.
Symbol : underline
Characteristics:
▪ Will not change in value
▪ Will not be null
▪ Simple

Candidate Identifier: an attribute that could be an identifier, it satisfies the


requirements for being an identifier.
o An entity may have multiple candidate identifiers but only needs one
identifier.
© 2021 Datapot Analytics. All rights reserved. 33
Exercise

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.

Create a single entity model for this scenario.

© 2021 Datapot Analytics. All rights reserved. 34


Relationship

▪ Relationship types vs. Relationship instances


o Relationship type is a meaningful association between (or among) entity
types.
o Relationship type is modeled as lines between entity types.
o Relationship instance is among specific entity instances.

▪ Relationship can have attributes: describe features related to the


association between the entities in the relationship.
▪ Two entities can have more than one type of relationship between them
(multiple relationships).
▪ Symbol : line

© 2021 Datapot Analytics. All rights reserved. 35


Relationship with Attributes

When the attributes depend on all the entities that participate in the relationship
(but not a single entity), the attributes belong to the relationship.

© 2021 Datapot Analytics. All rights reserved. 36


Relationship with Attributes (cont.)

Each employee has a common


Complete_Date and a common Grade
for all the courses he/she completes

All the employees completing a course


share the same Grade and same
Complete_Date

Each employee can complete different


courses at different Complete_Date
with different Grade
Each course can be taken by different
employees at different Complete_Date
with different Grade
© 2021 Datapot Analytics. All rights reserved. 37
Two important concepts in 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

© 2021 Datapot Analytics. All rights reserved. 38


Degree of Relationships

Degree of a relationship is the number of entities participating in the


relationship:
▪ Unary Relationship
▪ Binary Relationship
▪ Ternary Relationship
▪ Could be higher (rare case)

© 2021 Datapot Analytics. All rights reserved. 39


Degree of Relationships (Symbols)

Unary Ternary
Binary

One entity related Entities of Entities of


to another of the two different three different
same entity type types related types related to
to each other
© 2021 Datapot Analytics. All rights reserved. each other 40
Example

Binary Relationship between STUDENT Entity type and COURSE Entity type

STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address

© 2021 Datapot Analytics. All rights reserved. 41


© 2021 Datapot Analytics. All rights reserved.
Cardinality of Relationships
Cardinality of a relationship is the number of instances of one entity that can
or must be associated with each instance of another entity.

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

© 2021 Datapot Analytics. All rights reserved. 43


Cardinality of Relationships (cont.)
One – to – One Relationship

© 2021 Datapot Analytics. All rights reserved. 44


Cardinality of Relationships (cont.)

One – to – Many Relationship

© 2021 Datapot Analytics. All rights reserved. 45


Cardinality of Relationships (cont.)

Many – to – Many Relationship

© 2021 Datapot Analytics. All rights reserved. 46


Cardinality of Relationships (Symbols)

Combine Cardinality and Degree : Binary relationships

© 2021 Datapot Analytics. All rights reserved. 47


Cardinality of Relationships (Symbols)

Combine Cardinality and Degree : Unary relationships

© 2021 Datapot Analytics. All rights reserved. 48


Exercise

Determine which cardinality of relationship between STUDENT Entity and


COURSE Entity:
▪ Each student can register for multiple courses
▪ One course can have many students

STUDENT
COURSE
StudentID
Name Registed_for CourseID
Major Title
Campus_Address

© 2021 Datapot Analytics. All rights reserved. 49


Cardinality Constraints

Cardinality Constraints - the number of instances of one entity that can or must be
associated with each instance of another entity.

Minimal: one Minimal: zero


Maximal: one Maximal: one

Maximum Cardinality

Minimal: one Minimal: zero


Maximal: many Maximal: many

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

A course have to be registered by at least one (one or many) student 51

© 2021 Datapot Analytics. All rights reserved.


Exercise

Add minimum and maximum cardinality notation to following figures based on


given rules

1. An employee is managed by zero/one


employee.
2. An employee manages zero/one/many other
employees

1. A product belongs to one product line


2. A product line contains at least one
product

© 2021 Datapot Analytics. All rights reserved. 52


What we have learned

Key concepts ER Modeling


▪ Business rule ▪ Use entity-relationship model
▪ Entity to logically represent the data
o Entity type/Entity instance for an organization
▪ Attribute ▪ Entities in the business
environments
o Identifier (key attribute)
▪ Relationships among those
▪ Relationship entities
o Relationship type ▪ Attributes of both the entities
o Relationship cardinality and their relationships

© 2021 Datapot Analytics. All rights reserved. 53


Database Design

It’s time for your questions

© 2021 Datapot Analytics. All rights reserved.


THANK YOU !

© 2021 Datapot Analytics. All rights reserved.

You might also like