IELM 511: Information System design Introduction Part 1. ISD for well structured data – relational and other DBMS ISD for systems with non-uniformly structured.

Slides:



Advertisements
Similar presentations
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Advertisements

ER Modeling Case Studies
Functional Dependencies and Normalization for Relational Databases
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.
IELM 511: Information System design Introduction Part I. ISD for well structured data – relational and other DBMS Part II. ISD for systems with non-uniformly.
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Ms. Hatoon Al-Sagri CCIS – IS Department Normalization.
The Relational Model System Development Life Cycle Normalisation
Data Modeling and Relational Database Design ISYS 650.
IELM 511: Information System design Introduction Part 1. ISD for well structured data – relational and other DBMS ISD for systems with non-uniformly structured.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Logical Model Agenda - Informal Mapping ER-Diagram to Schemas
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
IELM 511: Information System design Introduction Part 1. ISD for well structured data – relational and other DBMS ISD for systems with non-uniformly structured.
IELM 511: Information System design
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Database Systems Chapter 7 ITM 354. Chapter Outline ER-to-Relational Schema Mapping Algorithm –Step 1: Mapping of Regular Entity Types –Step 2: Mapping.
Compe 301 ER - Model. Today DBMS Overview Data Modeling Going from conceptual requirements of a application to a concrete data model E/R Model.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Exam 2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
CAS CS 460/660 Entity/Relationship Model
Concepts and Terminology Introduction to Database.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Lecture 1 of Advanced Databases Basic Concepts Instructor: Mr.Ahmed Al Astal.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
SQL Structured Query Language Programming Course.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Functional Dependencies and Normalization for Relational Databases.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
How to build ER diagrams
BIS 360 – Lecture Eight Ch. 12: Database Design and Normalization.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
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.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Logical Database Design and the Relational Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Lecture 4: Logical Database Design and the Relational Model 1.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
COP Introduction to Database Structures
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Relational Database Design by Dr. S. Sridhar, Ph. D
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Session 2 Welcome: The seventh learning sequence
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Syllabus Study Introduction to database Relational algebra
Presentation transcript:

IELM 511: Information System design Introduction Part 1. ISD for well structured data – relational and other DBMS ISD for systems with non-uniformly structured data Part III: (one out of) Basics of web-based IS (www, web2.0, …) Markup’s, HTML, XML Design tools for Info Sys: UML API’s for mobile apps Security, Cryptography IS product lifecycles Algorithm analysis, P, NP, NPC Info storage (modeling, normalization) Info retrieval (Relational algebra, Calculus, SQL) DB integrated API’s

Agenda Relational design 1. Converting ER diagram into (a set of) DB tables 2. Normal forms – a theoretical basis for RDB design

Bank is organized in branches. Each branch is located in a particular city and identified by a unique name. The bank monitors the assets of each branch. (Recap) Example: Banking system Customers are identified by their SSN (equiv to HKID). The bank stores each customer’s name and address. Customers may have accounts, and can take out loans. A customer may be associated with a particular banker, who may act as a loan officer of personal banker for that customer. Bank employees are also identified by SSN. The bank stores the Name, address, phone #, start day of employment of each employee, the name of all dependents of the employee, and the manager of the employee. The bank offers two types of accounts: savings and checking. Accounts can be held by more than one customer, and a customer may have many accounts. Each account has a unique account number. We store each account’s balance, and the most recent date when the account was accessed by each customer holding the account. Each savings account has an interest rate, and overdrafts are recorded for each checking account. A loan originates art a particular branch, and is held by one or more customers. Each loan has a unique number. For each loan, the bank stores the loan amount and the payments (date and amount). Payment numbers are not unique, but a payment number uniquely identifies a payment for a specific loan.

1 n 1 n m n 1 n 1 n m n (Recap) Bank ER

Agenda Relational design 1. Converting ER diagram into (a set of) DB tables 2. Normal forms – a theoretical basis for RDB design

Converting ER into Relational tables: rationale There is an informal set of rules to convert ER diagrams into Tables This is a very good initial design for most DB’s Normalization can be used to verify/improve this initial design

Basic terminology - All data is stored in tables Columns: Attributes Rows: Tuples - Domain of an Attribute, A  set of values that A can have - Schema  TableName( A 1, A 2, …, A n ) - Tuple, t, of R(A 1, A 2, …, A n )  ORDERED set of values, v i  dom( A i ) All tables in a DB must obey four types of constraints

Constraints on DB tables A. Domain constraints t[A i ]  dom( A i ), for all t, A i B. Key constraints Superkey of R: A set of attributes, SK, of R such that t 1 [ SK] != t 2 [SK] whenever t 1 ≠ t 2 Key: minimal Superkey of R minimal: removal of any attribute from Key  no longer a Superkey of R

Constraints on tables.. B. Key constraints, examples: CAR( State, LicensePlateNo, VehicleID, Model, Year, Manufacturer) K1 = { State, LicensePlateNo} K1 is a minimal Superkey  Key K2 = { VehicleID }K2  Key (Why ?) K3 = { VehicleID, Manufacturer} Superkey ? Key ?

Constraints on tables... C. Entity Integrity constraints If PK is the Primary Key, then t[PK] != NULL for any tuple t  r( R) D. Referential constraints - All referential constraints must be defined - X(A i ) references Y(B j )  dom(A i ) = dom(B j ) - Foreign Key  attributes that reference a Primary Key Foreign Key examples CUSTOMERSSNName Address BankerSSN EMPLOYEESSNNameStartDateTelNoMgrSSN FK

Converting ER into Relational tables 1. For each regular entity, E, One table E with all the simple attributes of E. Select a primary key for E, and mark it. 2. For each binary relation type, R, between entity types, S and T: For 1:1 relationship between S and T Either add PK(S) as FK(T), or add PK(T) as FK(R) For 1:N relationship between S and T (S: the N-side) Add PK(T) as a foreign key in S. For M:N relationship, R, between S and T Create a new table, R, with the PK’s of S and T as FK’s of P, plus any attributes of R

Converting ER into Relational tables.. 3. For each weak entity type, W, whose identifying entity is E One table W with all attributes of W and the primary key of E mark the Primary Key 4. For each multi-valued attribute A, Create a new table, R, including A, plus PK of the entity/relationship containing A 5. For each n-ary relationship, R, with degree > 2 Create a table R, with PK of each participating entity as FK, plus all simple attributes of R

Converting ER into Relational tables… 6. Specializations* If P is the highest level entity of an aggregation type, with specialization entity types R and S. Then: Create a table for P, with each regular attribute of P. Create a table for each of R, S, each with all of their respective attributes, and the primary key of P. * we will ignore other, special cases of specialization.

Initial DB design for the bank ER: step 1 (entities) BRANCH( b-name, city, assets, …) CUSTOMER( cssn, c-name, street, city, ….) LOAN( l-no, amount, ….) PAYMENT( l-no, pay-no, date, amount, ….) EMPLOYEE( e-ssn, e-name, tel, start-date, ….) ACCOUNT( ac-no, balance, ….) SACCOUNT( ac-no, int-rate, ….) CACCOUNT( ac-no, od-amt, ….)

Initial DB design: step 2 (1-1, 1-n relationships) BRANCH( b-name, city, assets, …) CUSTOMER( cssn, c-name, street, city, banker, banker-type, ….) LOAN( l-no, amount, br-name, ….) PAYMENT( l-no, pay-no, date, amount, ….) EMPLOYEE( e-ssn, e-name, tel, start-date, mgr-ssn, ….) ACCOUNT( ac-no, balance, ….) SACCOUNT( ac-no, int-rate, ….) CACCOUNT( ac-no, od-amt, ….)

Initial DB design: step 3 (m-n relationships) BRANCH( b-name, city, assets, …) CUSTOMER( cssn, c-name, street, city, banker, banker-type, ….) LOAN( l-no, amount, br-name, ….) PAYMENT( l-no, pay-no, date, amount, ….) EMPLOYEE( e-ssn, e-name, tel, start-date, mgr-ssn, ….) ACCOUNT( ac-no, balance, ….) SACCOUNT( ac-no, int-rate, ….) CACCOUNT( ac-no, od-amt, ….) BORROWS( cust-ssn, loan-num, ….) DEPOSIT( c-ssn, ac-num, access-date….)

Initial DB design: step 4 (multi-valued attributes) BRANCH( b-name, city, assets) CUSTOMER( cssn, c-name, street, city, banker, banker-type) LOAN( l-no, amount, br-name) PAYMENT( l-no, pay-no, date, amount) EMPLOYEE( e-ssn, e-name, tel, start-date, mgr-ssn) ACCOUNT( ac-no, balance) SACCOUNT( ac-no, int-rate) CACCOUNT( ac-no, od-amt) BORROWS( cust-ssn, loan-num) DEPOSIT( c-ssn, ac-num, access-date) DEPENDENT( emp-ssn, dep-name)

Normalization: the theoretical basis for RDB design How can we tell if a DB design is ‘Good’ ? A DB Design is good if: (1) it provides a way to store all information in the system (2) the design is not bad How can we tell if a DB design is ‘Bad’ ?

Bad DB design examples: Normalization: the theoretical basis for RDB design CUST_LOAN( cssn, cname, addr, banker, banker-type, loan-no, amt, branch) CUST_DEPOSIT( cssn, cname, addr, banker, banker-type, ac-no, bal, access-date) (a) Information is stored redundantly (b) Insertion anomalies (c) Deletion Anomalies (d) Modification Anomalies

Normalization: the theoretical basis for RDB design.. Design requirement: Avoid too many NULL values in some rows STUDENT( SID, Name, Phone, , SocietyName, MemberNo) OR STUDENT( SID, Name, Phone, ) MEMBERSHIP( SID, SocietyName, MembershipNo)

Bad DB Designs.. - Spurious Tuples must not be created when ‘join’-ing tables Example: - Who supplied P2 to Proj2 ? -- the answer requires us to ‘join’ the two tables - Who supplied P1 to Proj2 ? supplies part supplier project part_no supp_no proj_no A (bad) design

Normal forms: functional dependencies A set of attributes, X, functionally determines a set of attributes Y if the value of X determines a unique value for Y. X  Y implies that for any two tuples, t 1 and t 2, if t 1 [X] = t 2 [X], then t 1 [ Y] = t 2 [ Y] NOTATION: X  Y Examples: In table CUSTOMER, {SSN}  {Customer name} In table PAYMENT, { l-no, pay-no}  { date, amount} Concept of FD is important in development of normalized DB designs.

First normal form, 1NF A table is in 1NF if it does not contain - any composite attributes, - any multi-valued attributes, - any nested relations Any non-1NF schema can be converted into a set of 1NF schemas SIDNameSemYrCourses 0401John SmithFall 05ie110, ie Jane DoeFall 05ie110, ie317 STUDENT_COURSES Not 1NF CompositeMulti-valued SIDLnameFnameSemYrCourse 0401SmithJohnFall05ie SmithJohnFall05ie DoeJaneFall05ie DoeJaneFall05ie317 STUDENT_COURSES_1NF 1NF

First normal form, 1NF.. 5P2 10P1 JohnSmith1123 JaneDoe3312 P3 P2 ProjNo 5 10 HoursFnameLnameSSN Projects EMPLOYEE_PROJECTS Nested Not 1NF JaneDoe3312 JohnSmith1123 FnameLnameSSN 5P P P P11123 HoursProjNoSSN EMPLOYEE EMP_PROJECTS 1NF

Second normal form, 2NF Prime Attribute: An attribute that is a member of the primary key Full functional Dependency: A FD, Y  Z, such that X  Z is false for all X  Y {SSN, PNumber}  {Hours} Full FD ? {SSN, PNumber}  EName Full FD ?

Second normal form, 2NF.. A schema R is in 2NF if every non-prime attribute A in R is fully functionally dependent on the primary key. Any non-2NF design can be converted into a set of 2NF designs is not in 2NF, because: PK = { cssn, ac-no}, but {cssn}  {cname}. CUST_DEPOSIT( cssn, cname, addr, banker, banker-type, ac-no, bal, access-date) CUSTOMER( cssn, c-name, addr, banker, banker-type) ACCOUNT( ac-no, balance) DEPOSIT( c-ssn, ac-num, access-date)

Third normal from, 3NF A Transitive Functional Dependency is an FD, Y  Z that can be derived from two FDs Y  X and X  Z. Example (poor DB design): CUST_BANKER( cssn, cname, addr, banker, banker-type, banker-mgr) {cssn}  {banker-mgr} is a transitive FD [why ?] Any non-3NF design can be converted into a set of 2NF designs CUSTOMER( cssn, c-name, street, city, banker, banker-type) EMPLOYEE( e-ssn, mgr-ssn)

Concluding remarks on normal forms 1. Normalized designs avoid problems associated with “bad” designs 2. Notice that informal ER diagram  Tables mapping yields 3NF schemas! 3. General 3NF: Notice our definition of 3NF depends on our selection of a PK. If a table has multiple choices of PK’s, then further problems may arise There is a general 3NF definition that avoids such issues. However, in practical cases, such issues are rare and outside our scope.

References and Further Reading Silberschatz, Korth, Sudarshan, Database Systems Concepts, McGraw Hill Next: Relational algebra, calculus, and SQL