Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Data model wikipedia , lookup

Business intelligence wikipedia , lookup

Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Versant Object Database wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Data vault modeling wikipedia , lookup

Relational algebra wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
91.2814/3 May 30, 2012
Name: _______________________________________________
Student Number: _______________________________________
1.What is a foreign key? What conditions
must be satisfied for the values of a
foreign key?
Foreign key (FK) is defined as follows:
i) Consider two relation schemas R1 and R2;
ii) The attributes in FK in R1 have the same
domain(s) as the primary key attributes PK in
R2; the attributes FK are said to reference or
refer to the relation R2;
iii) A value of FK in a tuple t1 of the current
state r(R1) either occurs as a value of PK for
some tuple t2 in the current state r(R2) or is null.
In the former case, we have t1[FK] = t2[PK],
and we say that the tuple t1 references or refers
to the tuple t2.
2
2. Describe the purposes of “input mask” and
“validation rule” for data fields.
The purpose of “input mark” is to facilitate the
data entry by displaying special literal characters
such as ‘-‘ for SSN attribute and ‘/’ for an
attribute whose data type is Date.
The purpose of a validation rule is to specify
some simple rules which must be satisfied by the
entered data for a certain attribute.
3.Specify the following concepts.
The cardinlity constraint for a binary
relationship specifies the number of
relationship instances that an entity can
participate in.
Three kinds of cardinality constraints:
1 : N, 1 : 1, M : N.
The participation constraint specifies
whether the existence of an entity depends
on its being related to another entity via
the relationship type.
Two kinds of participation relationships:
total and partial
A weak entity type is an entity type, for
which the primary key cannot be
recognized.
An identifying relationship exists between
a weak entity type and its owner.
4.Consider the following ERD. Map the
ERD to a relational database showing the
relation(s) that will be created (show
relation names, attributes, and primary
keys).
DeptNo
lName
phone
fName
Manager
Department
office
Department: [DeptNo, Manager_fName,
Manager_lName]
Phone: [DeptNo, phone]
Office: [DeptNo, office]
5.When you use the relationships tool in
Microsoft Access, the system indicates
whether the relationship is one-to-many or
one-to-one. How is the system able to
determine when the relationship must be
one-to-one?
Check both the attributes involved.
The indexed property of each is set to
Yes – No/duplicates.
Then, click and drag one of the two attributes from one
table to the other.
6. Consider the following ERD.
Lname
Fname
Person
PerBirthDate
PerNo
Now, consider the recursive relationship “a
person is the child of another person”.
a) Modify the ERD to accommodate this
relationship.
b) Show the relations (show the relation
name, attributes, and primary key) that
exist when you map your ERD in part a)
above to a relational database.
Suppose Sam and Silvia are children of
John and Jane. Make up other data for
these people and illustrate the contents of
your relation(s). Show the rows that must
exist in your relation(s).
c) Show how your answer to part a) appears
when the MS Access relationships tool is
used.
Answer:
a)
Lname
Fname
N
Person
PerBirthDate
M
childOf
PerNo
b)
Person: [PerNo, Lname, Fname, PerBirthDate]
ChildOf: [child, parent]
Person:
1
2
3
4
……
……
……
……
John
Jane
Sam
Silvia
ChildOf:
3
3
4
4
1
2
1
2
c)
PerNo
Lname
Fname
PerBirthDate
2
1

child
parent
child
parent
PerNo

1 Lname
Fname
PerBirthDate
7. When we create a relationship between two
tables A and B, we may choose, besides
“Enforce Referential Integrity”, “Cascade
Update Related Fields”, or “Cascade Delete
Related Records”. Please explain the
difference of these two choices.
If we choose “Enforce Referential Integrity”,
the referential integrity will be always checked.
That is, each time you change or delete the
relevant data, the corresponding referential
integrity will be examined. If the change or the
deletion will lead to a violation of the integrity,
the updating operation will not be carried out.
If we choose “Cascade Update Related Fields”,
each time we delete a record, the relevant data
field will be propagatingly updated.
If we choose “Cascade Delete Related Records”,
each time we delete a record, the relevant
records will be propagatingly updated.
8.Consider the following Vehicle table.
Vid
1
2
3
4
5
6
7
8
Make
Toyota
Honda
Toyota
Honda
Toyota
Honda
Toyota
Honda
Model
Celica
Prelude
Celica
Prelude
Celica
Prelude
Celica
Prelude
Colour
Red
Blue
Red
Blue
Red
Blue
Red
Blue
Kilos
Year
100000 1994
150000 1994
145000 1993
100000 1997
100000 1996
150000 1996
145000 1996
100000 1995
Price Sold
$15,000. Yes
$18,000.
00 No
$15,500.
00 Yes
$22,000.
00 Yes
$15,000.
00 No
$18,000.
00 Yes
$15,500.
00 Yes
$22,000.
00 No
00
A business analyst would like to see the
results of a query that shows how many
vehicles were sold in each year. Design
your query and show its definition in
Design View.
Answer:
9.Given the query below, show the
corresponding Query Design View.
Use an attached sheet for your answer.
Assume that Dealer and Auto are two
tables. Dealer has attributes: DealerId, and
name; and Auto has attributes: AutoId,
Make, Model, Year, Price, and Did, where
Did is a foreign key referring to DealerId.
For each dealer, find the number of the
autos with price > 10000, sold by it.
10. Consider the following design.
Name
Mid
wife
N
Marriage
MDate
1
Person
N
Pid
1
husband
Map this ERD to a relational database
(show relation names, attributes, and
primary keys)
Person: [Pid, Name]
Marriage: [Mid, Mdate, husband, wife]
11. Consider the following ERD.
PCode
PDesc
PName
w
Product
1
Brand
N
N
1
Category
BDesc
BName
Cat
CatDesc
a) Illustrate the relationships as they would be
shown in the MS Access Relationships
Tool.
b) Show the relation structure created for
Product when the ERD is mapped to a
relational database.
Answer:
a)
BName
BDesc
1

Cat
BName
CatDesc
1
1


PCode
PName
PDesc
Cat
BName
b)
Product: [Pcode, Pname, Pdesc, Cat, Nname]
12. Given the following relationship diagram:
8
Please give the query design views and SQL
views for the following queries:
a) Find the number of days between the
OrderDate and ShippedDate for the Order
made by the customer ‘VINET’.
b) Find any product name in the category of
Condiments and supplied by Mayumi’s.
Answer:
a)
b)