WeCodeAcademy

Practice: Design a Library Database

Put the whole design process together. A library lends books to members. Each book has a title and an author; a book can have several copies; a member can borrow many copies over time, and a copy is borrowed by one member at a time.

Entities: Author, Book, Copy, Member, Loan. Notice that Loan is the link between Member and Copy, and carries the dates. Build it with foreign keys, load some data, and ask questions with joins.

Examplepython
Open in editor »
Quick check

Which table links members and copies, carrying the dates?

Your turn: write the code

Count the copies of each book title (join books and copies) and print a list of (title, copies) ordered by title.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.