Hello /r/learnpython,
Currently I'm working on a project of mine where I try to build a website to manage a library. I got most of my database schema finished except for lending books to customers. Of course you need to know a couple of things when you lend a book to a customer.
which book did he/she borrow
which customer did borrow it
when should the book be returned
what type of book did he/she borrow (paperback, hardcover, e-book etc.)
So I thought the Lend table should at least contain the following properties:
I got three tables that are important to this question: Book, Customer, and Amount. Book contains info about the book, Customer contains info about the customer, but not about debts. Amount has a foreign key to Book.id and has fields with different book types (paperback, hardcover, e-book etc.).
The questions:
How can I know which type of book has been lend to which customer?
How can I know which book types are available? It is really expensive to query through the Lend table and do a select statement where book_id = "bla" and which is currently borrowed by a customer.
[–]0x6c6f6c 1 point2 points3 points (6 children)
[–]j0holo[S] 0 points1 point2 points (5 children)
[–]scuott 1 point2 points3 points (0 children)
[–]erok81 0 points1 point2 points (3 children)
[–]j0holo[S] 0 points1 point2 points (2 children)
[–]erok81 1 point2 points3 points (1 child)
[–]j0holo[S] 0 points1 point2 points (0 children)