CS 3630 Database Design and Implementation. 2 Design Methodology Three main phases 1.Conceptual database design Understanding client data E-R (EER) Model.

Slides:



Advertisements
Similar presentations
Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 1.
Advertisements

primary key constraint foreign key constraint
1 Assignment 4 Map entities with relationships to relational schemas. Use DBDL to describe the table schemas.
Assignment Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the.
CS 440 Database Management Systems Lecture 4: Constraints, Schema Design.
Ch 10, Functional Dependencies and Normal forms
Assignment6-1 Assignment6-2 Due Wednesday, March 13 1.
The Relational Model System Development Life Cycle Normalisation
Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.
1 Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the process of design.
CS 3630 Database Design and Implementation. First Normal Form (1NF) No multi-value attributes Done when mapping E-R model to relational schema DBDL 2.
1 CS 3630 Database Design and Implementation. 2 Final Exam 7:00 – 8:52 PM, Thursday, May 16 Section 1: Ull 009 Section 2: Ull Points –50 points.
© Pearson Education Limited, Chapter 12 Physical Database Design – Step 3 (Translate Logical Design) Transparencies.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Introduction to Databases. Case Example: File based Processing Real Estate Agent’s office Property for sale or rent Potential Buyer/renter Staff/employees.
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 5 Normalization of Database Tables
1 Test1 N = {n: n is an integer and n  0} X = {x: x = n + 5, where n  N} Y = {y: y = 7 * n - 1, where n  N} List the three smallest elements of each.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
Chapter 13 Normalization Transparencies. 2 Last Class u Access Lab.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Data Normalization Normal is not something to aspire to, it's something to get away from. ~ Jodie Foster ~
1 CS 3630 Database Design and Implementation. 2 Sets Foundation of relational database. Basic Operations Power set Mapping.
1 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An = {(x1, x2, x3, …, xn): xi  Ai} R  A1  A2.
Organizing Data Revision: pages 8-10, 31 Chapter 3.
CS 3630 Database Design and Implementation. 2 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
CS 3630 Database Design and Implementation. Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 2.
Design Process - Where are we?
© Pearson Education Limited, Normalization Bayu Adhi Tama, M.T.I. Faculty of Computer Science University of Sriwijaya.
Modelling Methodologies Chapter 16, 17, 18. Modeling Methodologies2 Database Design Physical DB design Logical DB design Conceptual DB design Hardware.
Second Normal Form (2NF) A relation R is in 1NF, and every non-primary-key attribute is fully functionally dependent on the primary key Then R is in 2NF.
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
CS 3630 Database Design and Implementation. Null Value The value of an attribute could be NULL NOT known at the moment or NOT Applicable Example Cell.
Ch 7: Normalization-Part 1
CS411 Database Systems Kazuhiro Minami 04: Relational Schema Design.
Assignment 5–2 For each new relation, Use DBDL to specify the relation scheme Give the functional dependencies Give the corresponding relation instance.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Database Architecture Normalization. Purpose of Normalization A technique for producing a set of relations with desirable properties, given the data requirements.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
CS 3630 Database Design and Implementation
Relational Schema Design II
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Normal Forms.
CS 3630 Database Design and Implementation
Relational Database Design by Dr. S. Sridhar, Ph. D
Assignment 4 Map entities with relationships to relational schemas.
Chapter 14 Normalization
CS 3630 Database Design and Implementation
Chapter 9 Designing Databases
Assignment 5–2 For each table, Give a meaningful name
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Boyce-Codd Normal Form (BCNF)
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Normalization Edited by: Nada Alhirabi.
Lectures 12: Design Theory I
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Presentation transcript:

CS 3630 Database Design and Implementation

2 Design Methodology Three main phases 1.Conceptual database design Understanding client data E-R (EER) Model Contract between clients and designers E-R Model could be used for any database system 2.Logical database design Step1: Mapping E-R Model to (relational) database schema Step2: Normalization 3.Physical database design

3 Normalization Relational Database A set of normalized relations. Normalization To get desired performance Data consistency 1NF, 2NF, 3NF, BCNF, 4NF and higher normal forms We stop at BCNF

4 Example: DreamHome Table schemas (after mapping): Staff (Sno, Name, Address, Phone, Bno) Branch (Bno, Address, Phone) Another Approach: Staff_and_Branch (Sno, Name, Address, Phone, Bno, BAddress, BPhone)

5 Problems Staff_and_Branch (Sno, Name, Address, Phone, Bno, BAddress, BPhone) Redundancy and Inconsistency Waste space : for each staff, store BAddress and BPhone Extra work on insertion: insert staff requires insertion of branch Extra work on updating: change BPhone, all staff in the branch Inconsistent data : when inserting and updating SnoNameAddressPhoneBnoBaddressBPhone S001.. B2020 main st, Platteville, WI S012.. B2020 main st, Platteville, WI S032.. B2020 main st, Platteville, WI S034.. B2020 main st, Platteville, WI S033.. B2025 main st, Platteville, WI

6 Example: DreamHome Table schemas Staff (Sno, Name, Address, Phone, Bno) Branch (Bno, Address, Phone) Another Approach: Staff_and_Branch (Sno, Name, Address, Phone, Bno, BAddress, BPhone) Major Issue Data Redundancy Data Inconsistency Normalization! Functional Dependency!

7 Functions A function is a mapping y = f(x) y1 = f(x1) y2 = f(x2) If x1 != x2 Then y1 != y2 NO! If x1 = x2 Then y1 = y2 YES!

8 Examples Example 1 y = f(x) = x 2 f(2) = f(-2) Is it possible that f(v1) != f(v2), but v1 = v2? NO! Example 2 y = g(x) = x 2 - 5x + 6 y1 = g(2) = 0 y2 = g(3) = 0 Is it possible that g(u1) != g(u2), but u1 = u2? NO!

9 Functions y = f(x) y1 = f(x1) y2 = f(x2) x1 = x2  y1 = y2 TrueFalse Same x value, then same y value. x1 != x2  y1 != y2 TrueFalse Different x values, then same or different y values. Is it possible that val1 = val2 but f(val1) != f(val2) NO! Not a function!

10 Functional Dependency Table schema (DBDL) from E-R Model R (A, B, C, D, E, F) PK: A AK: B, C FK: C references R1 Functional Dependency: B  D For any two records of R Same B value Same D value Different B values Same or different D values (We don’t care!) D = f(B) No such a function to calculate the value of D from that of B!

11 Example Staff_and_Branch (Sno, Name, Address, Bno, BAddress) PK: Sno AK: None FK: None FD: ???

12 Example Staff_and_Branch (Sno, Name, Address, Bno, BAddress) FD: Sno  Name(YES!) Address  Name(NO!) Name  Address(NO!) Bno  BAddress(YES!) BAddress  Bno(YES!) SnoNameAddressBnoBAddress S001J. Clifton102 mainB011 westhill S002M. Smith102 mainB023 easttown S013M. Smith20 mainB011 westhill

13 Functional Dependency R (A, B, C, D, E, F) PK: A AK: B, C FK: C references R1 Functional Dependencies: B  D For any two records of R Same B value Same D value Different B values Same or different D values (We don’t care!) B  D not true Find two records of R Same B value Different D values (val1 = val2 but f(val1) != f(val2))

14 Example Property (Pno, Address, Type, Ono, Oname) PK: Pno AK: Address FK: Ono references Owner FD: ???

15 Example Property (Pno, Address, Type, Ono, Oname) Pno  All(YES!) Address  All(YES!) Ono  All(NO!) Ono  OName(YES!) OName  Ono(NO!) PnoAddressTypeOnoOName P0011 MoonniteHouseO01J. Clifton P0023 SunnyHouseO02M. Smith P0139 S. Drive, U22ApartsO03J. Clifton P0149 S. Drive, U15ApartsO02M. Smith

16 Example A B C D 10 X 200 CS 20 X 300 CS 10 Y 200 SE 30 Y 200 SE 10 Y 200 CS 30 X 100 CS A  C ? Yes B  D? NO Same value implies same value Different values? We do not care! A  C? B  D?

17 Example A B C D 10 X 200 CS 20 X 300 SE 10 Y 200 CS 30 Y 200 CS 10 Y 200 CS 10 V 250 XX 30 Z ? EE 20 W ? CJ A  C ? Possible B  D? NO Business rules! Must be true for all table instances! Must be part of table schema and apply to all table instances! Not just from some table instances! Checking data entry if A  C is true!

18 Functional Dependency Definition Assume A and B are attributes of a table R. A  B (B is functionally dependent on A) If each value of A in R is associated with exactly one value of B in R. A is called Determinant. Any two records of R If they agree on A (have the same value on A), Then they will agree on B (have the same value on B). If they have different values on A, Then they may have different values or the same value on B. B = f(A)

Schedule Assignment 5-1 Due Wednesday, February 25 19