access database library assignment
DESCRIPTION
This presentation walks through some database theory on how to build a database for a library.TRANSCRIPT
![Page 1: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/1.jpg)
Library Assignment
![Page 2: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/2.jpg)
Let's try to understand one simple database
![Page 3: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/3.jpg)
A library allows customers to check out books
![Page 4: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/4.jpg)
So what tables do we need?
![Page 5: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/5.jpg)
Customer table: any data the library needs to keep about its customers
![Page 6: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/6.jpg)
Customer table primary key: Autonumber
![Page 7: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/7.jpg)
Book table: store any data the library needs to keep about its books
![Page 8: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/8.jpg)
Primary key for book table
![Page 9: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/9.jpg)
Is there a relationship between the book and customer table?
![Page 10: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/10.jpg)
To see if 2 tables have a relationship you must ask 3 questions.
![Page 11: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/11.jpg)
You have to ask 3 questions for each side of the relationship
![Page 12: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/12.jpg)
Could you have a book in the book table that no one has checked out?
![Page 13: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/13.jpg)
Could you have a book that 1 customer has checked out?
![Page 14: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/14.jpg)
Could you have a book that more than 1 customer has checked out?
![Page 15: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/15.jpg)
Since you can have a book checked out by more than one customer
Book Customer
M
![Page 16: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/16.jpg)
Could you have a customer in the customer table that has not checked out a book?
![Page 17: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/17.jpg)
Could you have a customer that has checked out 1 book?
![Page 18: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/18.jpg)
Could you have a customer that has checked out more than 1 book?
![Page 19: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/19.jpg)
This side of the relationship is also many!
Book Customer
M
![Page 20: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/20.jpg)
So we have a many to many relationship!
Book Customer
M M
![Page 21: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/21.jpg)
Each customer can check out more than one book and each book can be checked out by more than one customer
![Page 22: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/22.jpg)
We can’t track which book a customer checks out without adding a new table.
![Page 23: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/23.jpg)
To create a bridge table you start with the primary keys of the related tables
![Page 24: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/24.jpg)
What should be the primary key for the bridge table?
![Page 25: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/25.jpg)
Entity relationship diagram shows the relationship
customer checkout book
1 M 1M
![Page 26: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/26.jpg)
But a customer can check out more than one book at a time!
![Page 27: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/27.jpg)
So instead of creating a bridge table between customer and book tables we will create a check out table to show each time a customer checks out books.
![Page 28: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/28.jpg)
So we need a table to show each time a customer checks out books…
![Page 29: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/29.jpg)
…and another table to show exactly what books that customer checked out that day
![Page 30: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/30.jpg)
The Checkout_Book table would be the bridge or junction table here for the Book and Checkout tables many to many relationship.
![Page 31: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/31.jpg)
To enter data in this database
![Page 32: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/32.jpg)
You could not enter data about a customer checking out a book if…
![Page 33: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/33.jpg)
Questions?
![Page 34: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/34.jpg)
![Page 35: Access Database Library Assignment](https://reader033.vdocuments.site/reader033/viewer/2022061212/54956259ac7959182e8b4de2/html5/thumbnails/35.jpg)