Access Database Library Assignment

5,506 views

Published on

This presentation walks through some database theory on how to build a database for a library.

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,506
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
102
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • The first 3 questions are asked from the book table looking at the customer table. Here the answer is yes. You could have a new book for example.
  • Yes to this question.
  • Again yes to this question.
  • this side of the relationship is many and now we have to see what the other side of the relationship is.
  • The next 3 questions are asked from the customer table looking at the book table. Here the answer is yes.
  • Again yes!
  • And yes again.
  • Since a book could be checked out by more than one customer.
  • If this database only had 3 tables then there would have to be another entry for each book each customer checked out. We can do better than that!
  • So instead of a bridge table we will create a checkout table and bring the customer primary key over as the foreign key and also include a Date_Checked_Out field. To reduce errors and to save time we will have Access enter a default time of today for this field.What would be a good primary key for this table?
  • This is a bridge or junction table so we need both primary keys of the 2 tables in the many to many relationship to serve as foreign keys and here they both can be the primary key. We can never use just one of these two foreign keys as the primary key. And sometimes there are good reasons not to use both foreign keys as the primary key. But here we can totally eliminate errors like accidently entering the same book two times by using both foreign keys as the primary key.
  • Access Database Library Assignment

    1. 1. Library Assignment
    2. 2. Lets try to understand onesimple database
    3. 3. A library allows customersto check out books
    4. 4. So what tables do we need?
    5. 5. Customer table: any data thelibrary needs to keep about itscustomers
    6. 6. Customer table primary key:Autonumber
    7. 7. Book table: store any data thelibrary needs to keep about itsbooks
    8. 8. Primary key for book table
    9. 9. Is there a relationshipbetween the book andcustomer table?
    10. 10. To see if 2 tables have arelationship you must ask 3questions.
    11. 11. You have to ask 3 questionsfor each side of therelationship
    12. 12. Could you have a book in thebook table that no one haschecked out?
    13. 13. Could you have a book that 1customer has checked out?
    14. 14. Could you have a book thatmore than 1 customer haschecked out?
    15. 15. Since you can have a bookchecked out by more thanone customer M Book Customer
    16. 16. Could you have a customerin the customer table thathas not checked out a book?
    17. 17. Could you have a customerthat has checked out 1 book?
    18. 18. Could you have a customerthat has checked out morethan 1 book?
    19. 19. This side of the relationship isalso many! M Book Customer
    20. 20. So we have a many to manyrelationship! M M Book Customer
    21. 21. Each customer can check outmore than one book and eachbook can be checked out bymore than one customer
    22. 22. We can’t track which book acustomer checks out withoutadding a new table.
    23. 23. To create a bridge table youstart with the primary keys ofthe related tables
    24. 24. What should be the primarykey for the bridge table?
    25. 25. Entity relationship diagramshows the relationship 1 M M 1customer checkout book
    26. 26. But a customer can check outmore than one book at a time!
    27. 27. So instead of creating a bridgetable between customer andbook tables we will create acheck out table to show eachtime a customer checks outbooks.
    28. 28. So we need a table to showeach time a customer checksout books…
    29. 29. …and another table to showexactly what books thatcustomer checked out thatday
    30. 30. The Checkout_Book tablewould be the bridge orjunction table here for theBook and Checkout tablesmany to many relationship.
    31. 31. To enter data in thisdatabase
    32. 32. You could not enter data about acustomer checking out a book if…
    33. 33. Questions?

    ×