You are on page 1of 17

Principles of Database Design, Conclusions

AIMS 2710 R. Nakatsu

Customer Order Information


1. 2. 3. 4. 5. 6. 7. 8. Order Date Shipping Date Shipping Carrier Order Total Order Sales Tax Customer Telephone Customer Name Customer Address, City, State, Zip 9. Store Name 10. Store Address, City, State, Zip 11. Store Telephone 12. Item 1 Name 13. Item 1 Price 14. Item 1 Qty 15. Item 2 Name 16. Item 2 Price 17. Item 2 Qty 18. Item 3 Name 19. Item 3 Price 20. Item 3 Qty 21. Item 4 Name 22. Item 4 Price 23. Item 4 Qty

Whats wrong with this design?

Principles of Database Design


Normalization is a process that assigns attributes (fields) to tables such that data redundancies are eliminated or reduced. Four Rules of Thumb: 1. Single Themes: Break up a large table into separate themes, or subjects.

2. Field Uniqueness: Each field in a table should represent a unique type of information.

Principles of Normalization, Continued


3. Primary Keys: Each table must have a unique identifier, or primary key, that is made up of one or more fields in the table.

4. Field Independence: You must be able to make a change to the data in any field (other than a field in the primary key) without affecting the data in any other field.

Rule 4: Field Independence


Employee (Employee Number, Last Name, First Name, Job Class, Hourly Rate)
Employee Number Last Name First Name Job Class Hourly Rate

11 12 13

Smith Jones McKay

John Susan Bob

Mechanic Technician Mechanic

20 18 20

14
15 16

Owens
Chang Sarandon

Paula
Steve Sarah

Clerk
Mechanic Mechanic

15
20 20

In this example, Hourly Rate is dependent on Job Class. Why is the above a poor design?

Solution: Create Two Tables


Employee (Employee Number, Last Name, First Name, Job Class ID)
Employee Number 11 12 13 14 15 Last Name Smith Jones McKay Owens Chang First Name John Susan Bob Paula Steve Job Class ID 2 3 2 1 2

16

Sarandon

Sarah

Job Class ID is the link to the Job Class table.

Job Class (Job Class ID, Job Class, Hourly Rate)


Job Class ID 1 2 3 Job Class Clerk Mechanic Technician Hourly Rate 15 20 18

There are no more field dependencies!

Integrity of a Database
It is important that the data in a database is correct and consistent. Data integrity problems can occur due to: incorrect data entry data redundancy poor database design

Ways to Maintain Data Integrity

Entity Integrity (primary key must be unique and must not be null) Referential Integrity Field types (e.g., text, numeric, date, yes/no) Input masks (e.g., ISBN number, dates) Field validation rules (What are some examples?) Good design of input screens (user interfaces) Check digits

User Interface Design

2000 Prentice Hall

Check Digit Example


Add a check digit to validate a clerks data entry. The check digit is determined by some mathematical algorithm. Example: Multiply the first digit by 2; multiply the second digit by 3; multiply the third by 4; add the results; divide by 10 and take the remainder. 127 yields (1*2 + 2*3 + 7*4) / 10 = 36 / 10 for a check digit of 6.

Concurrency Control
Concurrency control is the management of concurrent transaction execution. Why is it important? The simultaneous execution of transactions over a shared database may create several dataintegrity and consistency problems.

Lost Updates: An Example


Time 1 2 3 4 5 6 Transaction Step Stored Value T1 Read QOH 50 T2 Read QOH 50 T1 QOH = 50 + 20 T2 QOH = 50 - 30 T1 Write QOH 70 T2 Write QOH 20

Note that the first transaction has not been permanently recorded when the second transaction is executed.

Concurrency Control with Locking


A lock guarantees exclusive use of a data item to a current transaction. In the previous example, transaction T2 will not have access to the data item that is currently used by transaction T1.

The lock is released when the transaction T1 is completed.

Data Warehouse
stores data that have been extracted from the various operational, external, and other databases of an organization Data warehouses...

support OLAP (online analytical processing) support data mining (data in a data warehouse are analyzed to reveal hidden patterns and trends in historical business activity)

Data Warehouse

Recap

Why do we need a database? What is a database? What are the main functions of a DBMS? Entity-Relationship Modeling Linking two tables: 1:1, 1:M, and M:N Four principles of database design Data Integrity Concurrency Control Data Warehouses

You might also like