Vous êtes sur la page 1sur 11

Database Management System

Investment: Manager, Stock, Portfolio, and Holding


Oracle Database
1) Create the Stock, Manager, Portfolio and Holding tables as shown above. Choose the name
of fields carefully. nclude a !rimary key clause for each table.
") #un the attached scri!t file, stock.s$l after making a!!ro!riate changes to your stock table
name.
%) nsert the data shown for the Manager table.
&) #un the attached scri!t file, !ortfolio.s$l to load the data into the Portfolio table.
') #un the attached scri!t file( holding.s$l to load the data into the Holding table.
Output result for stock:
Output result for portfolio:
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
Output result for holdin!:
Output result for mana!er:
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
)) *se the +,-.# -+/,. command to(
a. make manager number a foreign key in the Portfolio table.
b. make !ortfolio number and stock symbol foreign keys in the Holding table.
0) *se the +,-.# -+/,. command to add a check clause on the S+,+#1 column in the
Manager table to ensure the salary value is at least 2&3,333.
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
4) 5rite select statements for the following $ueries(
a" displa# the entries in the stock table in descendin! order of price
b" displa# all entries in the stock table $here the stock name starts $ith a %
c" displa# the portfolio number and stock s#mbol of all entries in the holdin! table
that ha&e more than '00 shares
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database

d" displa# the a&era!e price of stock in the stock table
e" usin! a (oin, displa# the portfolio number, cash, stock s#mbol and number of
shares from the portfolio and holdin! tables
Output One:
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
Output Two:
f" usin! a sub)uer#, displa# the stock name of all stock held in portfolio *008
6) Create the following views(
a. create a view called share7!rice that contains the !ortfolio number, stock symbol and
current !rice of the stock.
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
b. create a view called manager7cash that contains the manager number and the total
cash in !ortfolios managed by the manager.
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
13)8is!lay the stock name of all stock in !ortfolios managed by manager M"
a. using a 9oin

Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
b. using a sub$uery
11)8is!lay the stock name of all stock !urchased during Se!tember of 1664.
a. using a 9oin
b. using a sub$uery
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database
1")8is!lay the !ortfolio number of the !ortfolio that has the holding with the largest number of
shares in it
1%)8is!lay the !ortfolio number of the !ortfolio that has the holding with the largest current
value :number shares ; current !rice)
1&)8is!lay the stock name of all stock that is in !ortfolio P331 but not in !ortfolio P33'. Hint(
use <=<>- <
1'),ist all stock :stock symbol, name and current !rice) of all stock not included in any
!ortfolio( using <>- < using an outer 9oin
Zubaidah Abdul Rehman, 20042080, BI
Database Management System
Investment: Manager, Stock, Portfolio, and Holding
Oracle Database

1))?or all stock in the Stock table, list the stock symbol, stock name and the total value
:current !rice ; number shares) of the stock in all holdings.
10)?or each !ortfolio in the Portfolio table, list the !ortfolio number and total shares held in
that !ortfolio@ only include !ortfolios with more than two holdings.
References <otes(
SA, -utorial
+dditional SA, Slides
Zubaidah Abdul Rehman, 20042080, BI

Vous aimerez peut-être aussi