How many Foreign Keys will exist in the Task relation?. How many Foreign Keys will exist in the Project relation?. Consider the Project Relation after conversion to a relational schema..
Trang 1Week 6 Tutorial Questions Solutions
Database Analysis and Design (Swinburne University of Technology)
Week 6 Tutorial Questions Solutions
Database Analysis and Design (Swinburne University of Technology)
Trang 2Tutorial 6 – Discussion Questions for Week 6
1 Consider the ERD above When converted to a Relational Schema:
a How many Foreign Keys will exist in the Task relation? One
b How many Foreign Keys will exist in the Project relation? One
2 Consider the Project Relation (after conversion to a relational schema)
a What is the name of the Foreign Key in this relation? LeaderId
b Would this foreign key be allowed to have Null values? Yes
3 Consider the Task Relation (after conversion to a relational schema)
a What is the name of the Foreign Key in this relation? ProjectId
b Would this foreign key be allowed to have Null values? 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
c Which table would you have to create last? Leader, Project or Task? 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 True
b Task is a parent of Project False
c Leader is a parent of Task False
d Task is a parent of Leader False
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
L E A DER
LeaderID
Title
ProjectId
Le c Office
Supervises PRO J ECT
Name
Co s t
De s c ription
TaskId
TASK
has
Trang 3INF10002 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' ;
Trang 4f
g
h
i
j
Trang 5
INF10002 Tutorial 6
k
l
m
Trang 6
Assume that a relational schema and database has been built based on the ERD in Question 1
LEADER(LeaderId, Name)
PK (LeaderId)
TASK (TaskId, Description, Cost, ProjectId)
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 P.title, L.name
INNER JOIN Leader L
ON 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 T.description, T.cost, P.title, L.name
INNER JOIN Project P
ON T.ProjectId =P.ProjectId
INNER JOIN Leader L
ON P.LeaderId =L.LeaderId