Presentation is loading. Please wait.

Presentation is loading. Please wait.

DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.

Similar presentations


Presentation on theme: "DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design."— Presentation transcript:

1 DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design

2 DBSQL 4-2 Copyright © Genetic Computer School, Singapore 2009 Chapter 4 Overview Database Design Redundancy Issues Data Anomaly Functional Dependency Theory Normalization Drawbacks of Normalization Denormalization

3 DBSQL 4-3 Copyright © Genetic Computer School, Singapore 2009 Database Design DBMS is a program or a collection of programs, through which users interact with a database is a software system that enables users to define, create and maintain the database and which provides controlled access to this database.

4 DBSQL 4-4 Copyright © Genetic Computer School, Singapore 2009 Cont’ Database Processing

5 DBSQL 4-5 Copyright © Genetic Computer School, Singapore 2009 Database Development Process

6 DBSQL 4-6 Copyright © Genetic Computer School, Singapore 2009 Redundancy Issues Redundancy is the common problem when implementing a database. It means that duplication of data exists and the same data are stored in more than one place. If those redundant data are to be removed then it is possible that data might be lost, further data complications and problems may lead to anomalies. There are three pre-defined anomalies existing: insertion, deletion and updating of data.

7 DBSQL 4-7 Copyright © Genetic Computer School, Singapore 2009 Data anomalies Insert Delete Update

8 DBSQL 4-8 Copyright © Genetic Computer School, Singapore 2009 Functional Dependencies The functional dependency occurs when one attribute in a relation uniquely identifies another attribute. It can be denoted as ‘A  B’ which means that ‘B is functionally dependent upon A’.

9 DBSQL 4-9 Copyright © Genetic Computer School, Singapore 2009 Cont’ A  B It means: B is functionally dependent on A A determines B A is called determinant B is called object of the determinant

10 DBSQL 4-10 Copyright © Genetic Computer School, Singapore 2009 FD Inference Rules Subset Property Augmentation Transitivity Secondary rules Union Decomposition Pseudo-transitivity

11 DBSQL 4-11 Copyright © Genetic Computer School, Singapore 2009 Types of Dependency Functional Partial Transitive It is a candidate key that uniquely identifies a relation This is the situation that exists if it is necessary to only use a subset of the attributes of the composite determinant to identify its object. A transitive dependency exists when there is an intermediate functional dependency. If A  B, B  C and if A  C then it can be stated that the transitive dependency exists.

12 DBSQL 4-12 Copyright © Genetic Computer School, Singapore 2009 Normalization  Is a formal technique for analyzing relations based on their primary key (or candidate keys in the case of BCNF) and functional dependencies.  Normalization is often executed as a series of steps. Each step corresponds to a specific normal form, which has known properties.

13 DBSQL 4-13 Copyright © Genetic Computer School, Singapore 2009 Cont’  The technique involves a series of rules that can be tested against individual relations so that a database can be normalized to any degree.

14 DBSQL 4-14 Copyright © Genetic Computer School, Singapore 2009 Stages of Normalization Process

15 DBSQL 4-15 Copyright © Genetic Computer School, Singapore 2009 First Normal Form (1NF) A table is said to be in First Normal Formal if it only contains one and only one atomic value. In this stage repeating groups will also be eliminated. Removing repeating groups is the starting point in the quest to create tables that are as free of problems as possible. Tables without repeating groups are said to be in its First Normal Form (1NF).

16 DBSQL 4-16 Copyright © Genetic Computer School, Singapore 2009 Example Orders (OrderNum, OrderDate, (PartNum, NumOrdered)) Orders OrderNumOrderDatePartNumNumOrdered 2160810/20/2008AT9411 DR931 DW111 2161310/21/2008KL624 2161410/21/2008KT032 BV062 CD524 2161910/24/2008DR931 2162310/25/2008KV292 10/20/200821610 10/23/200821617

17 DBSQL 4-17 Copyright © Genetic Computer School, Singapore 2009 Second Normal Form (2NF) To convert a table into its Second Normal Form, it should first be in its First Normal Form (1NF). A table is said to be in its Second Normal Form if all of its non-key attributes only depends on one key attribute meaning no partial dependencies

18 DBSQL 4-18 Copyright © Genetic Computer School, Singapore 2009 Example Orders (OrderNum, OrderDate, PartNum, Description, NumOrdered, QuotedPrice)

19 DBSQL 4-19 Copyright © Genetic Computer School, Singapore 2009 Cont’ Orders (OrderNum, OrderDate) Part (PartNum, Description) OrderLine (OrderNum, PartNum, NumOrdered, QuotedPrice) Part (PartNum, Description) OrderLine (OrderNum, PartNum, NumOrdered, QuotedPrice)

20 DBSQL 4-20 Copyright © Genetic Computer School, Singapore 2009 Third Normal Form (3NF) The general concept of Third Normal Form (3NF) is to remove transitive dependencies.

21 DBSQL 4-21 Copyright © Genetic Computer School, Singapore 2009 Example Customer (CustID, CustName, CustAddress, Balance,CustCreditLimit, CustStatus, RepNo, FirstName, LastName) Representative (RepNo, FirstName, LastName) Customer (CustID, CustName, CustAddress, Balance,CustCreditLimit, CustStatus, RepNo)

22 DBSQL 4-22 Copyright © Genetic Computer School, Singapore 2009 Boyce Codd Normal Form (BCNF)  A relation is in BCNF, if for every non-trivial functional dependency X  A, X is a super key. In other words a relation is in BCNF, if and only if the determinant is a candidate key.  BCNF is a stronger form of normalization than 3NF, which eliminates the first rule of 3NF, which allows the right side of the functional dependency to be a prime attribute.

23 DBSQL 4-23 Copyright © Genetic Computer School, Singapore 2009 Fourth Normal Form (4NF) A table is in fourth normal form (4NF) when it is third normal form (3NF) and there are no multi-valued dependencies. Multi-valued dependencies A   B

24 DBSQL 4-24 Copyright © Genetic Computer School, Singapore 2009 Fifth Normal Form The goal of the Fifth Normal Form is to remove join dependency. In normalizing a relation seldom it would reach to this stage.

25 DBSQL 4-25 Copyright © Genetic Computer School, Singapore 2009 Drawbacks of Normalization It produces a lot of tables Might slow the performance when querying data at multiple tables Query becomes complex

26 DBSQL 4-26 Copyright © Genetic Computer School, Singapore 2009 Denormalization Denormalization is used primarily to improve performance in cases where a database and the relation itself are over normalized causing an overhead to the query processor.

27 DBSQL 4-27 Copyright © Genetic Computer School, Singapore 2009 End


Download ppt "DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design."

Similar presentations


Ads by Google