Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basic Database Design COSC 2328 – Web Programming.

Similar presentations


Presentation on theme: "Basic Database Design COSC 2328 – Web Programming."— Presentation transcript:

1 Basic Database Design COSC 2328 – Web Programming

2 The Design Process Determine the purpose of the database
Organize the information / divide the information into tables Turn information into columns Specify primary keys Setup table relationships Apply normalization rules

3 What is “Normalization”
Organizing the columns (attributes) and tables (relations) of a relational database Why? Reduce data redundancy Reduce storage requirements Improve data dependencies

4 3 Normal Forms No repeating elements or groups of elements
No partial dependencies on a concatenated key No dependencies on non-key attributes

5 Invoices

6 Tracking In A Spreadsheet
How many 56” Blue Freens were sold in 2002? What was the total sales of 3” Red Freens came from Washington DC in 2016?

7 Filling In The Data Oops – Now we have repeating elements

8 Creating A Composite Key
If we identify a primary key as the Invoice Number and Item ID, we get a unique key. There is no single column that identifies each row, but if we put the two columns together we now have a unique key.

9 No Partial Dependencies
Each column in the table that is not part of the primary key must depend on the entire concatenated key If any column only depends on one part of the key, then we say that the entire table fails second normal form Steps -- Take each column not part of the key. Can this column exist without one or the other part of the primary key? If ‘yes’ – even once – then the table fails Second Normal Form

10 Table Concepts Break-up the spreadsheet into multiple tables in a database Think about one-to-many and many-to-one relationships Determine which fields belong to which tables Use IDs to identify rows when necessary

11 Designing The Tables orders --------------------- orderId (PK)
customerId (FK) orderDate orderItems orderId (PK) (FK) itemId (PK) (FK) itemQuantity items itemId (PK) itemDescription itemPrice 1 n n 1 n 1 customers customerId (PK) customerName customerAddress customerCity customerState


Download ppt "Basic Database Design COSC 2328 – Web Programming."

Similar presentations


Ads by Google