diff options
| author | Kamal Wickramanayake <kamal@inbox.lk> | 2026-04-26 12:03:31 +0530 |
|---|---|---|
| committer | Kamal Wickramanayake <kamal@inbox.lk> | 2026-04-26 12:03:31 +0530 |
| commit | bd07dc92b8d99de6092349f56c6d3f233b26ad75 (patch) | |
| tree | 2c7a5f457de7cf2f9d914322dd167c3571faca38 /database | |
| parent | fb5455828b4ca31355468b4866a80270b3c3e12d (diff) | |
Added some more sql to library.sql
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; |
