You are on page 1of 3

AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB)

Faculty of Science and Information Technology


Department of Computer Science
Introduction to Database (Mid Lab Quiz)
Section: A
Semester: Summer 2015-16
Duration:
1:40 hrs
Branch
BranchNo
B002
B003
B004
B005
B007

Street
56 Clover Dr
163 Main St
32 Manse Rd
22 Deer Rd
16 Argyll St

Client
No
CR56

Fna
me
Aline

CR62

Mary

CR74

Mike

CR76

John

Owner
No
CO40

Fna
me
Sam

CO46

Joe

CO87

Coral

CO93

Tony

City
London
Glasgow
Los Angeles
London
Aberdeen

Client
Lnam
TelNo
e
Stewa 014184818
rt
25
Trege
012241967
ar
20
014753921
78
Kay
020777456
32
PrivateOwner
Lna
Address
me
Spad 63 Well St,
e
Glasgow
Keog 2 Fergus Dr,
h
Aberdeen
Farrel 6 Achray St,
Glasgow
Shaw 12 Park Pl,
Glasgow

Propert
Street
yNo
PA14
16
Holhead
PG16
5 Novar
Dr

Postcode
NW10 6EU
G11 9QX
BS99 1NZ
SW1 4EH
AB2 3SU

PrefTy
pe
Flat

MaxRe
nt
350

Villa

600

House

750

Flat

425

TelNo
01419431
728
01224861
212
01413577
419
01412257
025

PropertyForRent
City
Postc Typ Roo
ode
e
ms
Aberde AB7
Hou
6
en
5SU
se
Glasgo G12
Flat
4
w
9AX

Re Owner Staf
nt
No
No
65 CO46
SA9
0
45 CO93
SG14
0

Branc
hNo
B007
B003

PG21
PG36
PG4
PL94

18 Dale
Rd
2 Manor
Rd
6
Lawrence
6 Argyll
St

Glasgo
w
Glasgo
w
Glasgo
w
Londo
n

G12
G32
4QX
G11
9QX
NW2

Hou
se
Flat

Villa

Villa

StafN
o
SA9

Fnam
e
Mary

Lnam
e
Howe

SG14

David

Ford

SG37

Ann

Beech

SG5

Susan

Brand

SL21

John

White

Staf
Position Gende
r
Assistant Femal
e
Superviso Male
r
Assistant Femal
e
Manager
Femal
e
Manager
Male

SL41

Julie

Lee

Assistant

Femal
e

60
0
37
5
35
0
40
0

CO87

SG37

B003

CO93

SG37

B003

CO40

SG29

B003

CO87

SL41

B005

DOB

Salar Branch
y
No
19-Feb- 9000 B007
00
24-Mar- 1850 B003
08
0
11-Oct- 1240 B003
06
0
03-Jun-12 4400 B003
0
01-Oct- 3000 B005
15
0
13-Jun-05 8700 B005

This is a sample database for a certain Property dealing company. Now do the following queries.
1. Create all the tables mentioned above and following is the list of constraints for all the
tables:
Branch
BranchNo
PRIMARY KEY
PostCode
UNIQUE KEY
Client
ClientNo
PRIMARY KEY
TelNo
UNIQUE KEY
MaxRent
Value should be at least 0.
PrivateOwner
OwnerNo
PRIMARY KEY
TelNo
UNIQUE KEY
Address
NOT NULL
Fname
NOT NULL
Lname
NOT NULL
PropertyForRent
PropertyNo
PRIMARY KEY
OwnerNo
FOREIGN KEY
StafNo
FOREIGN KEY
BranchNo
FOREIGN KEY
Staf

StafNo
BranchNo

PRIMARY KEY
FOREIGN KEY

2. Insert at least two rows for each table.


3. Find all the information of the staffs those who are not only manager but also joined the
company before 2009.
4. Find all the branch which at least has lo in their location and show them as following
Branch B001 situated in Long Beach.
5. Find the full name, 25% bonus and with bonus new salary for all the staffs. Rename the
column as NAME, BONUS, and NEW SALARY.
6. Find the first name and telephone number for those clients who preferred either house
or flat for rent.
7. Find out all the job positions for this company.
8. Find out the full name, id, rent for all the clients those who wants to take rent from $250
to $390.
9. Find all the clients who want to take house for rent and dont have any last name.
10. Find all the information of the properties which are actually villa and have at least 6
rooms. Also the rent should be more than $219 but it cant be more than $401.
11. Show all the owners those who has got at least a o in their name and rename the
column as Name.
12. Show the id, street, city, rent and postcode for the properties according to higher to
lower rent rate.
13. Show the renting properties which belongs to B003 branch and also not house or villa.
14. Insert the last given row for branch and client table and then go back to previous state
when there was only two rows for each
15. Change the type of properties into villa for those which are situated in Glasgow and
rooms are more than five.
16. Delete all the female staffs those who are assistant.
17. Include a new column for client table to store email address for all the clients.
18. Remove the phone number column from clients.
19. Reintroduce PrivateOwner table as Owner table.
20. Add a comment for Branch table which will be following Branch Info
for company.
21. Change all the previous branch address of London into Manchester.
22. Remove all the values from Staff table.
23. Remove private owner table.
24. Save all the previous transactions.
25. Now show all the tables structures.

You might also like