Tải bản đầy đủ (.pdf) (6 trang)

week 6 tutorial questions solutions

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (359.21 KB, 6 trang )

lOMoARcPSD|9517029

Week 6 Tutorial Questions Solutions
Database Analysis and Design (Swinburne University of Technology)

StuDocu is not sponsored or endorsed by any college or university
Downloaded by qu? anh v? ()


lOMoARcPSD|9517029

Tutorial 6 – Discussion Questions for Week 6
LeaderID

ProjectId

Name

TaskId

Title

Description
Cost

LEADER

Supervises

PROJECT
LecOffice



has

1. Consider the ERD above. When converted to a Relational Schema:
a. How many Foreign Keys will exist in the Task relation?
b. How many Foreign Keys will exist in the Project relation?

TASK

One
One

2. Consider the Project Relation (after conversion to a relational schema).
a. What is the name of the Foreign Key in this relation?
b. Would this foreign key be allowed to have Null values?

LeaderId
Yes

3. Consider the Task Relation (after conversion to a relational schema).
a. What is the name of the Foreign Key in this relation?
b. Would this foreign key be allowed to have Null values?

ProjectId
No

4. Imagine that you now want to build the database based on the Relational Schema.
a. Which table would you have to create first? Leader, Project or Task?
Leader
b. Which table would you have to create second? Leader, Project or Task?

Project
Task
c. Which table would you have to create last? Leader, Project or Task?
5. What is a Parent row in a relational database?
A parent row is a row that contains a primary key value that is referenced by foreign key values.
6. What is a Child row in a relational database?
A child row is a row that contains a foreign key value that is references a primary key value.
7. True or False
a. Leader is a parent of Project.
b. Task is a parent of Project. False
c. Leader is a parent of Task. False
d. Task is a parent of Leader. False

True

8. When using Oracle in default mode, nominate if the following statements are True or False
a. A parent row that has no child rows may be deleted without error. True
b. A child row that has a parent row may be deleted without error
True
c. A child row may not be orphaned True
d. A parent row cannot exist without having child rows False
e. A parent row that has one or more child rows may be deleted without error. False

Downloaded by qu? anh v? ()


lOMoARcPSD|9517029

INF10002 Tutorial 6


9. Consider the following data in the Person table. How many rows are selected by the following Queries? a.

(Rick's quantities are unknown)
b.

(Rick's quantities are unknown)
c.

(Rick's quantities are unknown)

d.

e.
SELECT Name FROM person
WHERE NOT (QtyA + QtyB) < 10 AND Gender = 'F' ;
Two (3,6,)

Downloaded by qu? anh v? ()


lOMoARcPSD|9517029

INF10002 Tutorial 6

f.

g.

h.


i.

j.

Downloaded by qu? anh v? ()


lOMoARcPSD|9517029

INF10002 Tutorial 6

k.

l.

m.

Downloaded by qu? anh v? ()


lOMoARcPSD|9517029

INF10002 Tutorial 6

Assume that a relational schema and database has been built based on the ERD in Question 1.
LEADER(LeaderId, Name)

TASK (TaskId, Description, Cost, ProjectId)

PK (LeaderId)


PK (TaskId)
FK (ProjectId) References Project

PROJECT(ProjectId, Title, LeaderId)
PK (ProjectId)
FK (LeaderId) References Leader

10. Write a single SQL statement using INNER JOIN clauses and aliases that displays the project title
and leader name for each of the projects in the project table:
SELECT
FROM
INNER JOIN
ON

P.title, L.name
Project P
Leader L
P.LeaderId =L.LeaderId

11. Write a single SQL statement using INNER JOIN clauses and aliases that displays the task
description and cost, project title and leader name for each of the tasks in the task table.
SELECT
FROM
INNER JOIN
ON
INNER JOIN
ON

T.description, T.cost, P.title, L.name

Task T
Project P
T.ProjectId =P.ProjectId
Leader L
P.LeaderId =L.LeaderId

Downloaded by qu? anh v? ()



×