From bd07dc92b8d99de6092349f56c6d3f233b26ad75 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sun, 26 Apr 2026 12:03:31 +0530 Subject: Added some more sql to library.sql --- database/postgresql/02-library/library.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'database/postgresql/02-library/library.sql') diff --git a/database/postgresql/02-library/library.sql b/database/postgresql/02-library/library.sql index b104fbe..5a097df 100644 --- a/database/postgresql/02-library/library.sql +++ b/database/postgresql/02-library/library.sql @@ -27,3 +27,17 @@ create table borrowed_book ( bookid integer references book(bookid) on delete restrict, borrowed_time timestamp ); + +-- Warning! We assume uid and bookid to be consecutive integers starting from 1 +-- uid 1 borrowed bookid 1 +insert into borrowed_book (uid, bookid) values (1, 1); +-- uid 1 borrowed bookid 2 +insert into borrowed_book (uid, bookid) values (1, 2); +-- uid 2 borrowed bookid 2 +insert into borrowed_book (uid, bookid) values (2, 2); + +-- List all borrowed book data +select * from borrowed_book ; + +-- Print the book names of bookes borrowed by user with the username 'kamal' +select b.name from book as b, user_account as u, borrowed_book as bw where u.username = 'kamal' and u.uid = bw.uid and bw.bookid = b.bookid; -- cgit v1.2.3