Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Can anyone help me draw up a data model?
Old 02-12-2010, 12:29 PM Can anyone help me draw up a data model?
Novice Talker

Posts: 5
Trades: 0
Ok for my coursework i have to draw a data model for any scenario of my choice, we are allowed to take an existing data model from the internet, problem is, the teacher has been VERY specific about the relationships that have to be included in the model, and im finding it extremelly difficult to find something that possesses all these elements.

Could someone help me? Suggest a scenario to use and give examples of how each of these points would be covered? Or draw me up an example?

• At least one one-many relationship
• At least one decomposed many-many relationship-show the original many-many relationship
• At least one recursive relationship
• At least one one-one relationship
• 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

Thank you!
Jskirt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-12-2010, 01:29 PM Re: Can anyone help me draw up a data model?
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Draw up a model for an invoice with affiliates where the affiliates have parent affiliates. Products to invoices will give you your many to many relationship.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 02-12-2010, 03:53 PM Re: Can anyone help me draw up a data model?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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 ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-12-2010, 04:59 PM Re: Can anyone help me draw up a data model?
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
An entity with subtyping that has relationships with other entities that involve the super-type and at least one subtype.
An example:
Code:
  Person (supertype)
    Customer (subtype)
    Employee (subtype)

 Other Entities
   PaymentMethod
   Address
 
 Possible Relationships:
   1 Person has 1 or more Addresses (relationship to the supertype)
   1 Customer has 0 or more PaymentMethods (relationship to the subtype)
NOTE: If a relationship applied to all subtypes, then it applies to the supertype and not a subtype (generally speaking)
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 02-16-2010, 03:51 PM Re: Can anyone help me draw up a data model?
Novice Talker

Posts: 5
Trades: 0
@tripy.. just think of an entity as a table

I think i'm doing understand this a bit better now..

I think im going to make an employee database.. here's what ive got so far..

theres an employee table, each employee entity has a supervisorID which is either null, or contains another employeeID, linking back to another employee entity, this sorts out the recursive bullet point

an employee uses one work station, a work station is used by one employee, this is a one-to-one relationship

regarding subtyping, i want to seperate the employees into part-time and full-time, but im having trouble knowing what i need to change to do this, do i have an employee table and two tables related to this called full_time_employee and part_time_employee? what values should each of the tables hold? :/

sorry for such a late reply, i've not had a computer for a while! hope you guys can still help me!

Thanks

Last edited by Jskirt; 02-16-2010 at 07:05 PM..
Jskirt is offline
Reply With Quote
View Public Profile
 
Old 02-16-2010, 07:02 PM Re: Can anyone help me draw up a data model?
Novice Talker

Posts: 5
Trades: 0
I have drawn up a data model but i don't want to post it here, because i've noticed some of my classmates are finding this thread so i obviously don't want them to knick mine cause it could get lots of people into bother!

tripy or JeremyMiller ,would it be possible for you to PM me if you would like to have a look at it?

I will forward you a screenshot of it so you can see if it's any good? It isn't quite on the same lines as tripy suggested but i seem to have covered most of the points just not sure if it's feasable as a database. Thanks!

Last edited by Jskirt; 02-16-2010 at 07:16 PM..
Jskirt is offline
Reply With Quote
View Public Profile
 
Old 02-17-2010, 03:16 AM Re: Can anyone help me draw up a data model?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
just send it to me, I'l look through it.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-17-2010, 07:18 AM Re: Can anyone help me draw up a data model?
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by tripy View Post
just send it to me, I'l look through it.
okay! i shall do that now, thank you
Jskirt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can anyone help me draw up a data model?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.82998 seconds with 12 queries