Вы находитесь на странице: 1из 4

Exam 2 (1)

1. Nike Shoe Supplier Database:

CUSTOMERS (cust_no, cust_name, street, town, post_code, cr_limit, curr_bal) PRODUCTS (prod_cod, description, prod_group, list_price, qty_on_hand, remake_level, remake_qty) ORDERS (order_no, order_date, cust_no) ORDER_DETAILS (order_no, prod_cod, order_qty, order_price)

Some attributes, such as cust_name, are self-explanatory; however, others need some definition:

cr_limit: The maximum that a customer is allowed to owe curr_bal: The amount currently owed by the customer list_price: The advertised price for a single unit of a particular product remake_level: The level to which the quantity on hand is compared; if qty_on_hand falls below this level, then the Nikke shoe supplier company will usually make another batch (to the manufacturer) to avoid stockout. remake_qty: The quantity usually made in any new batch. order_price: The unit price charged on this order for this product order_date: The date on which the order was taken.

CUSTOMERS

Cust_no

Cust_name

Street

Town

 

Post_code

Cr_limit

Curr_bal

 

1066

Bundy Shoe

Kings St

Bundoora

3083

500

450

13144

Target

High St

Clayton

 

3800

3000

1000

1776

Harry Store

Elphin Rd

Hawthorn

3122

500

500

2001

Kmart

Burke Rd

Kew

 

3101

500

0

2002

Qshoe

Glen Rd

Kew

 

3101

1000

300

PRODUCTS

 

Prod_cod

Description

 

Prod_group

 

List_

Qty_on_

Remake_l

Remake_qt

 
   

price

hand

evel

y

MO9

Male Runner

 

Male Shoes

 

150

6

3

5

LO9

Lady Runner

 

Female Shoes

 

250

1

1

3

ST1

Girls Runner

 

Female Shoes

 

300

10

5

15

LT1

Tennis Shoe

 

General

 

450

1

2

2

LT9

Tennis Shoe

 

General

 

100

20

15

20

GN9

Beach Sandal

 

General

 

10

100

150

200

ST1

Slipper

 

General

 

50

50

35

20

GA2

Soccer Shoe

 

Male Shoes

 

500

10

15

40

ORDERS

ORDER_DETAILS

 

Order_no

Order_date

Cust_no

 

Order_no

Prod_cod

 

Order_qty

Order_

0001

01/07/93

13144

0001

ST1

10

45

0002

02/07/93

13144

0001

GA2

 

2

480

0003

02/07/93

1066

0002

ST1

5

45

 

0003

GN9

 

10

10

a. Show the result of this the following relational algebra query

prod_cod,description,list_price,order_date cr_limit-curr_bal>=500 (CUSTOMERS

ORDERS*ORDER_DETAILS)

*

b. Find out the optimal algebra expression for (a)

Write SQL statement

PRODUCTS

*

c.

corresponding to the above the algebra query (a)

d. list the details of customers who do not have any orders.

e. display the details of customer who has the maximum available credit (available credit is the cr_limit minus the curr_bal).

f. list of order no. and the total value of that order. The list contains only those orders worth more than $1000

g. list details of customer and the total order value between 01/01/1993 đến 4/12/1993 in descending order of total value

h. list the details of product and the total value of product sold by day

2. The Victorian Basketball Conference is an amateur basketball association. Each city in the state has one team that represents it. Teams are identified by their id and name. Each team has a maximum of twelve players and a minimum of nine players. Players are identified by a unique player id, and their name, address and contact phone number needs to be recorded. Each team also has up to two coaches (offensive and defensive). Coaches also have unique ids, and their name, address, and contact phone number are required. Each team plays two games (home and visitor) against each of the other teams during the season. Information needs to be kept regarding the venue of the game and the final score. As a special treat at the end of the season the association holds a break-up party for the players. At the break-up party treats are given out to all the players’ children who are under The association therefore requires each child’s name and date of birth. Note: A city will only be in this database if it has a team Coach and player may not yet be assigned to a team (a player could be in the draft for instance )

Exam 2 (2)

1. Nike Shoe Supplier Database:

CUSTOMERS (cust_no, cust_name, street, town, post_code, cr_limit, curr_bal) PRODUCTS (prod_cod, description, prod_group, list_price, qty_on_hand, remake_level, remake_qty) ORDERS (order_no, order_date, cust_no) ORDER_DETAILS (order_no, prod_cod, order_qty, order_price)

Some attributes, such as cust_name, are self-explanatory; however, others need some definition:

cr_limit: The maximum that a customer is allowed to owe curr_bal: The amount currently owed by the customer list_price: The advertised price for a single unit of a particular product remake_level: The level to which the quantity on hand is compared; if qty_on_hand falls below this level, then the Nikke shoe supplier company will usually make another batch (to the manufacturer) to avoid stockout. remake_qty: The quantity usually made in any new batch. order_price: The unit price charged on this order for this product order_date: The date on which the order was taken.

CUSTOMERS

Cust_no

Cust_name

Street

Town

 

Post_code

Cr_limit

Curr_bal

 

1066

Bundy Shoe

Kings St

Bundoora

3083

500

450

13144

Target

High St

Clayton

 

3800

3000

1000

1776

Harry Store

Elphin Rd

Hawthorn

3122

500

500

2001

Kmart

Burke Rd

Kew

 

3101

500

0

2002

Qshoe

Glen Rd

Kew

 

3101

1000

300

PRODUCTS

 

Prod_cod

Description

 

Prod_group

 

List_

Qty_on_

Remake_l

Remake_qt

 
   

price

hand

evel

y

MO9

Male Runner

 

Male Shoes

 

150

6

3

5

LO9

Lady Runner

 

Female Shoes

 

250

1

1

3

ST1

Girls Runner

 

Female Shoes

 

300

10

5

15

LT1

Tennis Shoe

 

General

 

450

1

2

2

LT9

Tennis Shoe

 

General

 

100

20

15

20

GN9

Beach Sandal

 

General

 

10

100

150

200

ST1

Slipper

 

General

 

50

50

35

20

GA2

Soccer Shoe

 

Male Shoes

 

500

10

15

40

ORDERS

ORDER_DETAILS

 

Order_no

Order_date

Cust_no

 

Order_no

Prod_cod

 

Order_qty

Order_

0001

01/07/93

13144

0001

ST1

10

45

0002

02/07/93

13144

0001

GA2

 

2

480

0003

02/07/93

1066

0002

ST1

5

45

 

0003

GN9

 

10

10

a. Show the result of this the following relational algebra query

prod_cod,description,list_price,order_date cr_limit-curr_bal>=500 (CUSTOMERS * PRODUCTS * ORDERS*ORDER_DETAILS)

b. Find out the optimal algebra expression for (a)

Write SQL statement

c.

corresponding to the above the algebra query (a)

d. list the details of products that is not in any orders.

e. display the details of best selling products (max quantity or max total value), their quantity and total value

f. list of order no. and the total value of that order between 01/01/1993 đến 4/12/1993 in

descending order of total value

g. list details of customer and the number of their order by month

h. list the details of product and the total value of product sold by day

2. You are required to derive a set of normalized relations for the following user views of La Trobe Hospital’s Statement of account, Room utilization report, and Physician Report. Make sure all relations are in 3NF (Third Normal Form).

 

La Trobe Hospital 1 Plenty Road, Bundoora 3083

Statement of account for:

Patient Name: Baker, Mary Patient Address: 30 High St Suburb-Post Code: Kew 3105

Patient No: 3456 Date Admitted: 26/01/2006 Date Discharged: 27/01/2006

Item Code

Description

Charge

200

Room

150.00

205

Television

10.00

307

X-Ray

25.00

413

Lab Tests

35.00

 

Balance Due

220.00

Note: Only one date admitted and one date discharged need to be stored for each patient (you are not required to store the history of the patient).

 

Room Utilization Report Date: 30/01/2006

 

Location

Type of

Patient No

Patient Name

Discharge Date

Accommodation

100-1

Private

3456

Baker, Mary

27/01/2006

100-2

Private

     

100-3

Semi-Private

     

100-4

Semi-Private

1345

Rose, David

03/02/2006

100-5

Private

2345

Miller, Ruth

06/02/2006

Note: A patient can only stay in one particular room, however a room may contain more than one patient.

 

La Trobe Hospital

 
 

Physician Report Physician ID: Wilcox

Date: 30/01/2006 Physician Phone: 1212

 

Patient

Patient Name

Procedure Location

Procedure

Procedure Date and Time

3456

Baker, Mary

190-1

Tonsillectomy

26/01/2006 09:00

1345

Rose, David

232-2

Observation

26/01/2006 11:00

2345

Miller, Ruth

237-2

Observation

27/01/2006 15:00

2345

Miller, Ruth

237-2

X-Ray

28/01/2006 09:00

2345

Miller, Ruth

235-2

Chemotherapy

29/01/2006 16:00