Database DesignDatabase Development Lifecycle
Database Design: Intro
Database SystemProvides data collection, storage, and retrievalComposed of people, hardware, software, database(s), procedures, and application programs
Database DesignFoundation of a successful database systemShould promote• Data integrity• Prevent data redundancies 반복 & anomalies 오류Must yield a database that• is efficient in its provision of data access.• meet the objectives of the database system and
serves the needs of its users.
Database Design 2
Data Redundancy
Database Systems: Design, Implementation, & Management: Rob & Coronel
Database Design 3
Data Anomaly Update anomalies 수정오류
- Data inconsistencies resulting from “islands of information” problem Insertion Anomalies 삽입오류
- Creation of bogus record when adding new data (e.g. new agent) Deletion Anomalies 삭제오류
- Unintended deletion of related data (e.g. agent data when deleting customer)
Database Systems: Design, Implementation, & Management: Rob & Coronel
Database Design 4
Database Development System Construction
System Analysis• Establish the need and extent of an information systemSystem Development• Design & implement the information system
Database ConstructionPlanning & Analysis 기획분석→ Analyze data environment & Define database objectives
Database Development• Design 설계
→ Construct a data model & establish data management processes
• Implementation 구현→ Create the storage structure (e.g., tables) & user interface for data management
• Maintenance 정비→ (corrective & adaptive) modification, backup & recovery
Database Design 5
Database Development Lifecycle
Planning & Analysis기획분석
Design개념 설계
Implementation구현
Maintenance정비
• Database Objectives
• Business Rules• Data Model
• DBMS Tables• User Interface• SQL Queries
• Modification• Backup & Recovery• Security
Database Design 6
Database Lifecycle: Planning & Analysis
Define Database Objectives What will the database (DB) do?
• What tasks 업무/작업will the DB support?→ Data Entry, Update, Search
• What information will the DB provide?→ Q & A
← Study the DB environment• How does the business operate?• Who are the players?• How does the information flow?
← Examine the data
Database Design 7
Planning & Analysis Database Design Implement Maintain
Sample Q&A: Recipe Database
Query Result
recipe name recipe info (ingredients, steps, …)
ingredients
recipe names → recipe info
main ingredient (meat, fish, …)
recipe type (diet, diabetic, …)
recipe category (soup, desert, …)
budget, time
Database Lifecycle: Database Design
Create a Database Model→ that can achieve the database objectives
1. Conceptual Design – ER Modeling2. Logical Design – Relational Schema & Normalization3. Physical Design – Schema into DBMS (Table Creation)
What is a Database Model?→ Abstract data structure of the real-world items← Need to understand how business works &
what role data plays
Database Design 8
Planning & Analysis Database Design Implement Maintain
Database Design: Conceptual Design
Conceptual Design Steps1. Enumerate the Business Rules
→ How does the business work?
2. Construct the Data Model→ Identify Entities, Relationship & draw an ER Diagram
Database Design 9
Planning & Analysis Database Design Implement Maintain
Conceptual Design: Business Rules
WhatBrief, precise, and unambiguous descriptions of operations in an organization• Based on policies, procedures, or principles within a specific organization
WhyPromote creation of an accurate data model← Enhance understanding & facilitate communication
How (sources)Interviews, Documentation, Observation
Examples• A painter can draw many paintings.
A painting is drawn by a single painter.
• A teacher can teach 0 to 6 courses per semester.• A course is taught by a single teacher. • A student must take at least 1 and at most 6 courses.• A course can have 10 to 40 students.
PAINTER PAINTINGdraws1 M
TEACHER COURSEteaches1 M
STUDENT
takes
M
N
Database Design 10
Planning & Analysis Database Design Implement Maintain
Conceptual Design: Data Modeling
What is Data Modeling?A model is a representation of reality
that retains only carefully selected essential details.Logical organization of data
for optimum information extraction and data manipulation
Why Model?To understand and identify essential data elements
How?Identify Entities 개체, Attributes 속성, & Relationships 관계
STUDENT
TEACHER
ID
GPA
Major
Name
Office
Database Design 11
Planning & Analysis Database Design Implement Maintain
Database Design: Relational Schema
Specification of the overall structure/organization of a database Relations
Entities w/ Attributes Primary key
• Unique identifier Foreign key
PK of related table Relationship type (connectivity)
• 1:M, M:N, 1:1
Database Design 12
Planning & Analysis Database Design Implement Maintain
https://www.coursera.org/learn/analytics-mysql/lecture/hDLIS/relational-schemas
Database Design: Data Dictionary
Detailed description of a data model• Lists attribute names and characteristics for each table in the database• Blueprint & documentation of a database
Database Design 13
Planning & Analysis Database Design Implement Maintain
Database Systems: Design, Implementation, & Management: Rob & Coronel
Database Design: Lifecycle1. Define Database Objectives
What information will the database provide?
2. Examine the Data Environment How does the business work & what data are used?
3. Construct the Data Modela. Enumerate the Business Rule.b. Identify Entities & Relationships between them.c. Define Attributes (and primary & foreign keys) for each entityd. Create an initial E-R diagrame. Normalize the entities 개체 정규화
→ Process for evaluating & designing good table structures
4. Verify the Data Model Does the data model support the database objectives?⇒ If not, modify the Data Model
Database Design 14
Data Model: University Example
Database Design 15
Exercises
1. Draw an E-R Diagram of the data model described by the business rules below.• One region can be the location for many stores. Each store is located in only one region.• Each store employs one or more employees. Each employee is employed by one store.• A job can be assigned to many employees.
-- e.g., The "Sales Representative" job can be assigned to more than one employee at a time.• Each employee can have only one job assignment.
Data Modeling Exercises
1. Draw an E-R Diagram of the data model described by the business rules below.• One region can be the location for many stores. Each store is located in only one region.• Each store employs one or more employees. Each employee is employed by one store.• A job can be assigned to many employees.
-- e.g., The "Sales Representative" job can be assigned to more than one employee at a time.• Each employee can have only one job assignment.
1. Draw an E-R Diagram of the data model described by the business rules below.• One region can be the location for many stores. Each store is located in only one region.• Each store employs one or more employees. Each employee is employed by one store.• A job can be assigned to many employees.
-- e.g., The "Sales Representative" job can be assigned to more than one employee at a time.• Each employee can have only one job assignment.
REGION
EMPLOYEEemployees
M
is location for
STORE
M1
1
JOB
1
M
is assigned to
Database Design 17
2. Identify the business rules and draw an E-R diagram of the situation described below.
For each professor, there may be multiple advisees. A professor teaches many classes and a class is taught by one professor.
Data Modeling Exercises
PROFESSOR CLASSteaches
advises
STUDENT
M
1
1
M
Business Rules• A professor can advise many students.• A student is advised by one professor.• A professor can teach many classes.• A class is taught by one professor
Database Design 18
3. Create a data model (i.e. ERD) for the school database described below.DB will keep track of advising and class information. DB should provide following information.- The list of students advised for a given year & dates of advising sessions for each students- Course listing for each year & student grades for each class
Data Modeling Exercises
PROFESSOR CLASSteaches
advises
STUDENT
M
1
1
M
Business Rules• A professor can advise many students. A student is advised by one professor.• A professor can teach many classes. A class is taught by one professor.• A student can take many classes. A class can have many students.• A course can generate many classes. A class is generated by one course.• A professor can meet many times with an advisee. A student can meet many times with the advisor.
COURSE
takes
3. Create a data model (i.e. ERD) for the school database described below.DB will keep track of advising and class information. DB should provide following information.- The list of students advised for a given year & dates of advising sessions for each students- Course listing for each year & student grades for each class
generates
1
M
3. Create a data model (i.e. ERD) for the school database described below.DB will keep track of advising and class information. DB should provide following information.- The list of students advised for a given year & dates of advising sessions for each students- Course listing for each year & student grades for each class
Database Design 19
M
M
1
1
ADVISING
1
1
M
M
ENROLL
3. Create a data model (i.e. ERD) for the school database described below.DB will keep track of advising and class information. DB should provide following information.- The list of students advised for a given year & dates of advising sessions for each students- Course listing for each year & student grades for each class
M
N
Sample DB