diff options
Diffstat (limited to 'database')
| -rw-r--r-- | database/postgresql/02-library/library.sql | 14 |
1 files changed, 14 insertions, 0 deletions
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; |
