You are on page 1of 6

Database Management System (DBMS) Lab Assignment -1, Fourth Semester

(Faculty: Pro ! "! P! #yas) ($As: Bharat Singh, %i&hi 'ush(aha, Moni)a, *iten&era, A+oor,, Abhay, Shuchi, Dee+ti, -e.u, Su.ata, Ar+it, Anan&, Shruti, /arshal, Saini))

Date o assignment: 00n& *an 0112 Due Date: 03th *an 0112
%ote: 1) All Assignments shoul& be &one in&e+en&ently! 0) $he Assignments (ill be &iscusse& a ter the &ue &ate so submission (ithin the &ea&line is essential! 4) Practical ile is com+ulsory or all stu&ents an& must contain han&(ritten solutions o 5uestion gi,en lab!

61! You have to create a database for general store information management system. Items can be described with
a unique item number, item name, selling price, manufacturer name. The item can be sold to a particular customer where each customer will have a unique customer number, customer name, customer addresses, city, pin - code, state and total amount required to be paid. Each customer, order to a buy item from the salesman. In the order, it has unique sales order number, sales order date, customer number, salesman number (unique , billed payment by the party or not and its delivery date. The salesman have the name, addresses, city, pin code, state, salary of the sales man, delivery date, total quantity ordered, item rate. You have to create the four tables with the fields mentioned above along with the data given below for each table. 7tem table item8i& i!!" i!!( i!!* i!!) i!!% i!!& i!!' i!!, item8name lu#$soap copy goodday$biscuit reynolds$pen sql$boo+s tata$steel seagate hdd dvd writer Manu8name lu#$company royal$noteboo+ britania$stores pen$par+er boo+$bpb tata$sons hp$world moserbear$org item8rate "%.&' ").,! ((",.,! (!"%.&' %"!).,! %"",.,! %"!).,! %"",.,! Sell8+ri9e (!.)* "&.)! (((!.)! ("(!.)* %""&.)! %"(!.)! %""&.)! %"(!.)! item8&iscri+tion soap copy biscuit pen boo+ tata -.."!*) ./.01

:ustomer table :ust8i& cu!"!!" cu!"!!( cu!"!!) :ust 8name ala+ roy suman roy priya das A&&ress b.d.para pu+ para chora para :ity 2atna patna 5aya Pin ,!!!"% ,!!"*( ,!!!"! State 3ihar 3ihar 3ihar Bal8&ue ! (*4!.4 "*4!.4

cu!"!!% cu!"!!& cu!"!!' cu!"!!, cu!"!!4 cu!"!!* cu!"!"! cu!"!""

rina ra6 pula+ roy priyan+a das +usum roy mina das nidhi mishra +amal yadav manali das

+amal para bircity nappam 7halwa naini naini naini ra6apur

patna luc+now luc+now allahabad allahabad allahabad allahabad allahabad

,!!!!" ((&!"( ((&!!% (""!"( (""!', ("(!'4 (""!*' ("(!4,

3ihar uttar pradesh uttar pradesh uttar pradesh uttar pradesh uttar pradesh uttar pradesh uttar pradesh

! ""!.4 "4!.4 ""!.4 ! 444!.4 (44!.4 *44!.4

Salesman table Salesman8i& s!!" s!!( s!!* s!!) s!!% s!!& s!!' Salesman8name rohan singh rohan singh smita roy +abir bora neha singh priya agarwal asho+ paul A&&ress ra6apur naini indira nagar vi+as nagar gomti nagar gandhi road filmcity :ity allhabad allhabad luc+now luc+now luc+now *( distric munnabari Pin ("(!4, ("(!4& ((&!', ((&!)% ((&!*( '44'%! '44')! State uttar pradesh uttar pradesh uttar pradesh uttar pradesh uttar pradesh delhi mumbai Salary ,!!! 4,!! *)!! &'!! 4&!! 44!! ,4!!

Sales8or&er8 no
son!"!!" son!"!!( son!"!!* son!"!!) son!"!!% son!"!!& son!"!!' son!"!!, son!"!!4

Sales8or&er 8&ate
!"-aug-(!!, "(-aug-(!!, "(-aug-(!!, "*-aug-(!!, ")-aug-(!!, "%-aug-(!!, "&-aug-(!!, "&-6an-(!!, !"-feb-(!!,

cust 8i&

Salesman8 i&
s!!" s!!" s!!( s!!" s!!( s!!" s!!) s!!* s!!*

Bill8+ayb y8+arty
yes yes yes yes no yes yes yes no

Deli,ery8 &ate
(!-aug-(!!, (*-aug-(!!, (&-aug-(!!, (!-aug-(!!, *!-aug-(!!, *"-aug-(!!, (,-aug-(!!, !(-aug-(!!, (,-aug-(!!,

item8rat e
(((!.)! (((!.)! (((!.)! (((!.)! (((!.)! (((!.)! (((!.)! (*4!.!! ,((!.)!

$ot85u antity8 or&er


%! "% "! "% %( )* %) *) %)

:ancel8&ate

cu!"!!" cu!"!!) cu!"!!% cu!"!!) cu!"!!( cu!"!!" cu!"!!* cu!"!!) cu!"!!)

null null null null (,-march-(!!, null null null ",-march-(!!,

Sales or&er table

For the tables create& abo,e, (rite the S6L 5ueries or the ollo(ing ; " ( * ) 0etrieve the list of names and the cities of the entire customer. 8ist the various items available. 9ind the names of all customer having :a; as the second letter in their names. 8ist the customer who is located in <llahabad.

% & ' , 4

9ind the item whose selling price is greater than (!!! and less than or equal to %!!!. <dd a new column =E1$20I>E into the Item table. 0ename the column item$rate of ?ales$@rder to new$item$rate. 8ist the Item in sorted order of their description. .isplay the order number and date on which the customer placed their order.

"! .elete all the records having delivery date before (%th <ugust (!!,. "" >hange the delivery date of order number ?@=!"!!, to "&-!,-!,. "( >hange the bal$due of cust$no >A!"!!* to "(!!. "* >hange the ?ell$price of ./. writer to *!!!. ") 9ind the item with description as :-.."!*); and :./.01;. "% 8ist the names, city and state of the customer not in the state of :Attar 2radesh;. "& 8ist of all orders that were canceled in the month of Barch. "' Apdate the salaryC"!!!! of D0ohan ?inghE who is from naini, <llahabad. ", <dd the field >ust$mobile in customer table that can holds a number up to "!-digit in length. "4 0etrieve customer information that is =@T in allahabad @0 luc+now. (! 9ind the names of all customerFcustomers whose name isFare starting with the letter :p;. (" 0etrieve ?ales$order$date, cust $id, ?alesman$id, .elivery$date from ?ales@rder table where the value contained within the field Tot$quantity$order is between"% to %!. (( .isplay the customer id whose delivery date is :*!-aug-(!!,;. (* .isplay the sales order date and delivery date in the following format.
G-intH use >@=/E0T ( , 5ET.<TE ( I

a. b. c.

dd-mm-yy("(-!*-,' dd-mm-yyyy("(-!*-"4,' dd mm yy("( !* ,'

() .isplay the cust$name which starts with any character, followed by JanJ from the J>ustomerJ table. (% .isplay the cust$name which starts with JpriJ, followed by any three characters, followed by JanJ, followed by any character, followed by JaJ from the J>ustomerJ table. (& .isplay the ?alesman$name which starts with JrJ or JsJ or J+J from the J?alesmanJ table.

(' .estroy the ?ales order table and all the data held in it. (, .isplay the system date and time. (4 .isplay the columns and their attributes of the >ustomer table. *! 0ename the table ?alesman to ?ales$man.

60! :reate the Follo(ing $ables an& ans(er the liste& 5ueries
Branch $able Branch8name 3righton .owntown Bianus =orth Town 2erryridge 2ownal 0edwood 0ound -ill Branch8city 3roo+lyn 3roo+lyn -orsenec+ 0ye -orsenec+ 3ennington 2alo <lto -orsenec+ Assets '"!!!!! 4!!!!!! )!!!!! *'!!!!! "'!!!!! *!!!!! ("!!!!! ,!!!!!!

:ustomer $able :ustomer8na me <dams 3roo+s >urry :ustomer8street :ustomer8city

?pring ?enator =orth

2ittsfield 3roo+lyn 0ye

5lenn -ayes 5reen 7ohnson 7ones 8indsay ?mith Turner 1illiams Loan $able Loan8numbe r 8-"" 8-") 8-"% 8-"& 8-"' 8-(* 8-4* Borro(er $able :ustomer8nam e <dams >urry -ayes 7ac+son 7ones ?mith ?mith 1illiams

?and -ill Bain 1alnut <lma Bain 2ar+ =orth 2utnam =assau

1oodside -arrison ?tamford 2alo <lto -arrison 2ittsfield 0ye ?tamford 2rinceton

Branch8name 0ound -ill .owntown 2erryridge 2erryridge .owntown 0edwood Bianus

Amount 4!! "%!! "%!! "*!! "!!! (!!! %!!

Loan8number 8-"& 8-4* 8-"% 8-") 8-"' 8-"" 8-(* 8-"'

Account $able Account8numbe r <-"!" <-("% <-"!( <-*!% <-(!" <-((( <-("' Branch8name .owntown Bianus 2erryridge 0ound -ill 3righton 0edwood 3righton Balance %!! '!! )!! *%! 4!! '!! '%!

De+ositor $able :ustomer8nam Account8number e -ayes <-"!( 7ohnson <-"!" 7ohnson <-(!" 7ones <-("' 8indsay <-((( ?mith <-("% Turner <-*!% <rite the S6L 5ueries on the bases o abo,e = tables!

". (. *. ). %. &. '. ,. 4. "!. "". "(. "*. "). "%. "&. "'. ",. "4. (!.

.isplay the tuples of the loan relation where the branch is D2erryridgeE. 9ind those customers who live in -arrison city. 9ind the names of all customers who have a loan at the ban+, and find the amount of the loan. 9ind the names of all branches in the loan relation. 9ind all loan numbers for loans made at the D.owntownE branch with loan amounts greater that K"!!!. 9ind the loan number of those loans with loan amounts between K",)!! and K(,!!!. 9or all customers who have a loan from the ban+, find their names, loan numbers. 9or all customers who have a loan from the ban+, find their names, loan numbers, and loan amount. 9ind the names of all branches that have assets greater than at least one branch located in -orsenec+. 9ind the names of all customers whose street address includes the substring :;=orth;;. 8ist the name of the customers in alphabetical order, who have a loan at the D2erryridgeE branch. 9ind the average account balance at each branch. 9ind the number of depositors for each branch. 9ind all loan numbers that appear in the loan relation with null values for amount. 9ind all customers who have both a loan and an account at the ban+. 9ind all customers who have both an account and a loan at the 2erryridge branch. 9ind all customers who do have a loan at the ban+, but do not have an account at the ban+. 9ind the names of all branches that have assets greater than those of at least one branch located in 3roo+lyn. 1rite a Luery for following situation. 3an+ wants to present a new K(!! savings account as a gift to all loan customers of the 2erryridge branch, for each loan they have.

You might also like