Содержание
- 2. Take the following table. StudentID is the primary key. Is it 1NF?
- 3. No. There are repeating groups (subject, subjectcost, grade) How can you make it 1NF?
- 4. Create new rows so each cell contains only one value But now look – is the
- 5. No – the studentID no longer uniquely identifies each row You now need to declare studentID
- 6. So. We now have 1NF. Is it 2NF?
- 7. Studentname and address are dependent on studentID (which is part of the key) This is good.
- 8. And 2NF requires… All non-key fields are dependent on the ENTIRE key (studentID + subject)
- 9. So it’s not 2NF How can we fix it?
- 10. Make new tables Make a new table for each primary key field Give each new table
- 11. Step 1 STUDENT TABLE (key = StudentID)
- 12. Step 2 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject)
- 13. Step 3 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key =
- 14. Step 3 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key =
- 15. Step 4 - relationships STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 16. Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 17. Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 18. Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 19. Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 20. A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 21. A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 22. A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 23. But is it 3NF? STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE
- 24. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 25. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 26. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 27. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 28. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 29. A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key
- 30. Again, carve off the offending fields SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)
- 31. A 3NF fix SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) 1 1 8
- 32. A 3NF fix SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) 1 1 8
- 33. A 3NF win! Or…
- 34. The Reveal Before… After… RESULTS TABLE (key = StudentID+Subject) 1 1 8 8 1 8 SUBJECTS
- 36. Скачать презентацию