Você está na página 1de 5

SQL Assignment Library System Use the following Schema to perform the given set of assignment.

TablesMember It contains information abo t the members !ol mn "ame #ata Type #escription Member_Id Number(5) Unique Member ID Member_Name Varchar2(30) Name of the Library member Member_addre Varchar2(50) !ddre of the member !cc_"#en_Date Date Date of member hi# Member hi#_ty#e Varchar2(20) $y#e of the member hi# uch a %Lifetime&'& !nnua(&' %)a(f *ear(y&'& +uarter(y& ,ee _#aid Number(-) Member hi# fee #aid Ma._/oo0 _!((o1ed Number(2) $ota( Number of boo0 that can be i ued to the member2 3ena(ty_!mount Number(4'2) 3ena(ty amount due $oo%s- It contains information abo t the boo%s belongs to the library !ol mn "ame #ata Type #escription /oo0_No Number(5) /oo0 identification number /oo0_Name Var6har2(30) Name of the boo0 !uthor_name Varchar2(30) !uthor of the boo0 6o t Number(4'2) 6o t of the boo0 6ate7ory 6har(80) 6ate7ory (i0e 9cience ' ,iction etc2 Iss e It contains the information abo t iss e of the boo%s !ol mn "ame #ata Type #escription Lib_I ue_Id Number(80) Library /oo0 I ue No /oo0_No Number(5) Number of the boo0 i ued Member_Id Number(5) Member that i ued the boo0 I ue_Date Date Date of I ue :eturn_date Date :eturn date

#ay & ' Assignments (; timated $ime< 2 )r ) !oncept< 9+L /a ic ' DDL command = 6reate tab(e 1ithout con traint and 1ith con traint ' !(ter' truncate' and Dro# DML command In ert' U#date' De(ete' $ran action 6ontro( 6ommit' :o((bac0' 9a>e#oint2 6reate equence command

(b)ective< !t the end of the a i7nment ' #artici#ant 1i(( be ab(e to under tand ba ic DDL ? DML? $ran action 6ontro( tatement 2 Tas% * +roblems<
1) Create the table Member, Books and Issue without any constraints as mentioned in the schema description above. 2) View the structure o the tables. !) "rop the Member table #) Create the table Member a$ain as per the schema description with the ollowin$ constraints. a.

b.

Member%Id & 'rimary (ey Membership%type ) %Lifetime&'& !nnua(&' %)a(f *ear(y&'& +uarter(y&

*) Modi y the table Member increase the width o the member name to !+ characters. ,) -dd a column named as .e erence o Char/!+) to Issue table. 0) "elete1"rop the column .e erence rom Issue. 2) .ename the table Issue to 3ib%Issue. 4) Insert ollowin$ data in table Member
Membe r ID Membe r Name .icha 5harma 6arima 5en Membe r Address 'une 'une Acc_Open_Date Membership_type Fees_Paid Max_Books _Allowed * ! Penalty_ Amount *+ 7ull

1 2

1+)"ec)+* current date

3i etime -nnual

2*+++ 1+++

1+) Insert at least * records with suitable data and save it. 11) Modi y the column Member_name. "ecrease the width o the member name to 2+ characters. /I it does not allow state the reason or that) 12) 8ry to insert a record with Ma9%Books%-llowed : 11+, ;bserve the error that comes. .eport the reason or this error. 1!) 6enerate another table named Member ! usin$ a Create command alon$ with a simple 5<3 =uery on member table.

1#) -dd the constraints on columns ma9%books%allowed and penalty%amt as ollows a. ma9%books%allowed > 1++ b. penalty%amt ma9imum 1+++ -lso $ive names to the constraints. 1*) "rop the table books. 1,) Create table Books a$ain as per the schema description with the ollowin$ constraints. a. Book%7o & 'rimary (ey b. Book%7ame & 7ot 7ull c. Cate$ory & 5cience, ?iction, "atabase, ."BM5, ;thers. 10) Insert data in Book table as ollows@ Book_N o 1+1 1+2 1+! 1+# Book Name 3et us C ;racle & Complete .e Masterin$ 5<3 '3 5<3).e Author "enis .itchie 3oni 3oni 5cott Arman "ost #*+ **+ 2*+ 0*+ "ate#ory 5ystem "atabase "atabase "atabase

12) Insert more records in Book table usin$ B operator in the insert statement. 14) Create table Book1+1 similar to Book in structure with no data in it. 2+) Insert into Book1+1 all the data in Book table usin$ 5elect 5tatement. 21) 5ave all the data so ar inserted in the tables. 22) View the data in the tables usin$ simple 5<3 =uery. 2!) Insert into Book ollowin$ data. 1+*, 7ational 6eo$raphic, -dis 5cott, 1+++, 5cience 2#) Ando the last chan$es. 2*) Modi y the price o book with id 1+! to .s !++ and cate$ory to ."BM5. 2,) .ename the table 3ib%Issue to Issue. 20) "rop table Issue. 22) -s per the $iven structure Create table Issue a$ain with ollowin$ constraints. 3ib%Issue%Id)'rimary key Book%7o) orei$n key Member%id ) orei$n key Issue%date >: system date. Issue%date > .eturn%date

24)

Insert ollowin$ data into Issue table. 7ote leave the column .eturn%"ate blank. Book No 1+1 1+2 1+# 1+1 1+# 1+1 Member ID 1 2 1 1 2 ! Issue Date 1+)"ec)+, 2*)"ec)+, 1*)Can)+, +#)Cul)+, 1*)7ov)+, 12)?eb)+, %eturn Date

$ib_Issu e_Id 0++1 0++2 0++! 0++# 0++* 0++,

!+) 5ave the data. !1) "isable the constraints on Issue table !2) Insert a record in Issue table. 8he member%id should not e9ist in member table. !!) 7ow enable the constraints o Issue table. ;bserve the error !#) "elete the record inserted at <)!2) and enable the constraints. !*) 8ry to delete the record o member id 1 rom member table and observe the error . !,) Modi y the .eturn%"ate o 0++#,0++* to 1* days a ter the Issue%date. !0) Modi y the 'enalty%-mount or 6arima 5en to .s 1++. !2) 'er orm a save point D here. !4) .emove all the records rom Issue table where member%I" is 1 and Issue date in be ore 1+)"ec)+,. #+) .emove all the records rom Book table with cate$ory other than ."BM5 and "atabase. #1) Ando the chan$es done a ter savepoint D. #2) 5ave all the chan$es done be ore D. #!) .emove the table Member1+1. ##) .emove the table Book1+1. #*) View the data and structure o all the three tables Member, Issue, Book. #,) Create a se=uence no_se& o even numbers startin$ with 1++ and endin$ with 2++. #0) "rop the above created se=uence. #2) Create a se=uence book%se= startin$ with 1+1 and endin$ with 1+++ -nd increamented by 1 without cycle. #4) Create a se=uence member%se= startin$ with 1 and endin$ with 1++ -nd increamented by 1 without cycle. *+) "rop the above created se=uences.