1 / 28

D111-Data Fundamentals

D111-Data Fundamentals. Normalisation Second Normal Form (2NF). Objectives. Introduction to Database Normalization Second Normal Form Database Forms with MS Access Database Queries with MS Access. What is Normalisation?. un- normalised tables. Normalisation Process.

tobit
Download Presentation

D111-Data Fundamentals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. D111-Data Fundamentals Normalisation Second Normal Form (2NF)

  2. Objectives • Introduction to Database Normalization • Second Normal Form • Database Forms with MS Access • Database Queries with MS Access

  3. What is Normalisation? un- normalised tables Normalisation Process The ideal table structures The process of decomposing large, inefficiently structured tables into smaller, more efficiently structured tables without losing any data in the process.

  4. The Normalization Process Remove repeating and multi-valued attributes Remove partially dependent attributes Remove transitively dependent attributes Apply additional normal forms (?)

  5. First Normal Form (1NF) Rules of 1NF: • No Repeating Groups • Data item cannot be broken down any further (atomic) • Each column has an unique name • Each row must have a unique identifier (Primary Key).

  6. Our Example 1Name: Jim Hicks 1.6

  7. Invoice in Spreadsheet format

  8. What are Repeating Groups? Row Repeating Group

  9. Another examples of Repeating data

  10. Atomic Data? • A piece of information that is broken down into the smallest pieces of data. • For example a date is divisible into day, month and year components • Split your information in as small parts as you think are convenient for your use.

  11. Atomic Teach-ICT.com

  12. Primary Key • The purpose of a primary key field is to provide a value that will can be used to uniquely identify each row in a table. • Each non primary key value is then dependant on that primary key to be found.

  13. Each row must have a unique identifier (Primary Key). Look for a field/s as a possible candidate/s to use for the Primary Key (CANDIDATE KEYS) What is the main purpose for this table? To hold invoice details - so InvoiceNo would be a good start Obviously on its own InvoiceNo cannot be the PK. You may need more than one field to locate the exact record

  14. Each row must have a unique identifier (Primary Key). What other field/s are a candidate for a concatenated PK ProductID and Description Why would we choose the ProductID? Smaller size and easy to maintain

  15. Check for Unique Column Names InvoiceNopk + ProductIDpk

  16. Remove the Repeating Group • Place the repeating group data in its own table but take the entire primary key with it. (WHY?) We need the InvoiceNo to link back to the main invoice table Notice the smaller table? Repeating group data

  17. The ERD as it stands at this point INVOICE INVOICE_PRODUCT

  18. Second Normal Form (2NF) • For a table to be in Second Normal Form: • Every non-key field must depend on the entire primary key, not part of a concatenated primary key. • If a database has only single-field primary keys, it is automatically in Second Normal Form.

  19. Partial Dependancies Already in 2NF Partial dependencies?

  20. Finding the Partial Dependencies Would only a single Description value be returned by search the table using InvoiceID 1234? SELECT Description FROM Table WHERE InvoiceNo = 1234 No, because it would return;

  21. Finding the Partial Dependencies Would only a single Description value be returned by search the table using ProductID 1? SELECT Description FROM Table WHERE ProductID = 1 Yes, because it would only return;

  22. Finding the Partial Dependencies • Remove partial dependencies to there own table but take a copy of the primary key it depends on with it. (Why?) Notice the reduced redundancy?

  23. Finding the Partial Dependencies • What about the rest?

  24. Tables should look like the following: INVOICE INVOICE_PRODUCT Both unique Qty and SalePrice values depend on the Concatenated Primary Key. LineTotal is eliminated because it is a derived column made by calculating the total of Qty * SalePrice PRODUCT

  25. The ERD as it stands at this point INVOICE INVOICE_PRODUCT PRODUCT

  26. See if you can get this table to meet the rules of 2NF CONCERT • Every non-key field must depend on the entire primary key, • not on part of a concatenated primary key.

  27. Answer CONCERT BAND

  28. References http://www.teach-ict.com/as_a2_ict_new/ocr/AS_G061/315_database_concepts/normalisation/miniweb/index.htm

More Related