Quote:
|
• At least one one-many relationship
|
That's easy. Why not a registration system that allow a user to register several emails:
For a "users" table, have the fields
Code:
userId => primary key
firstName
lastName
sex
and a table "emails":
Code:
userFk => foreign key to users.userId. Primary key
email
You will have a 1 (the user profile) to many (each emails) relationship.
Quote:
|
• At least one decomposed many-many relationship-show the original many-many relationship
|
I don't understand what is a "decomposed many to many" relationship, so I'm not sure but:
Given the "users" table previous example.
We will give the users the possibility to tag their profile.
To do so, you need a "tags" table:
Code:
tagId => primary key
tagName
and a table to do the link between the tags and the profiles, "userTags":
Code:
userFk => foreign key to users.userId. First part of the composite primary key
tagFk => foreign key to tags.tagId. Second part of the composite primary key
This gives you a 1 to many relationship from the "users" to the "userTags" table.
And a many to one relationship from the "userTags" to the "tags" table, resulting in an effective many to many from the users to the tags.
I hope that this is the "decomposed" part.
Quote:
|
• At least one recursive relationship
|
I'll take an bit of a db I work on for that.
A bit of theory first.
I work in a enterprise that produces programs to manage a pharmacy. Some medecines are to be given only upon a prescription, given by a doctor. It's a prescription.
A prescription can be renewable. The legislation here forces us to be able to trace every renewal to the first delivery. We do it that way:
The "prescription" table:
Code:
prescriptionId => primary key
saleDate
prescriptionNr
prescriptionFk
When a first deliver is made, en entry is done into the prescription table. The field "presciptionFk" is null.
When a renewal of tha prescription is done, we insert another record in that table, but this time, the field presciptionFk have the value of the "prescriptionId" of the first delivery.
There is your recursivity.
Quote:
|
• At least one one-one relationship
|
Ha, easy!
Take the "users" table from the beginning.
Create a "sex" table:
Code:
sexId => primary key
sexValue
You create a 1 to 1 relationship by allowing only 1 sex to be tied for each profiles.
Quote:
• An entity with subtyping that has relationships with other entities that involve the super-type and at least one subtype.
• No less than 8 entities, no more than 10
|
Hu !?
Here, I have to admit that I am completely lost.
What is an entity? What is subtyping and a super-type in a sql database ?