1. 4 copies of a new book Distributed and Cloud Computing has been added to the
ID: 3593312 • Letter: 1
Question
1. 4 copies of a new book Distributed and Cloud Computing has been added to the library. The price is $50.00 for each copy. Add the information to the book relation. Assume that bookid is automatically maintained by the system.
2. One of the checkout records is incorrect. It turns out, the student with id 4 never checked out the book with id 1. He checked out the book with id 2. Update the information in book_checkout relation.
Explanation / Answer
1. 4 copies of a new book Distributed and Cloud Computing has been added to the library.
The price is $50.00 for each copy. Add the information to the book relation.
Assume that bookid is automatically maintained by the system.
book(bookid, title, price, total_copies)
The row ("Distributed and Cloud Computing", 50.00, 4) is to be added.
INSERT INTO book (title, price, total_copies) VALUES ("Distributed and Cloud Computing", 50.00, 4);
will insert the given row into the table book.
2. One of the checkout records is incorrect.
It turns out, the student with id 4 never checked out the book with id 1.
He checked out the book with id 2. Update the information in book_checkout relation.
('2017-09-07', 1, 4) should be modified to ('2017-09-07', 2, 4)
So, the update query is:
UPDATE book_checkout SET bookid = 2 WHERE bookid = 1 AND studentid = 4;
Don't forget to use both the conditions, unless otherwise, it will modify 2 rows instead of 1.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.