If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > A couple Design questions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-10, 23:22
CrimsonK CrimsonK is offline
Registered User
 
Join Date: Dec 2010
Posts: 2
A couple Design questions

I am designing a database for a class and I was wondering a couple things.

I have come up with 7 entities and basically my tables correspond one entity. After drawing an E-R diagram it I didn't find that I needed any extra tables. Is this bad that I came up with the same amount of tables as I did entities?

Also I had a further indepth question. How would you handle creating a table in which one of it's columns needs to refer to two similar but different tables. I'll give an example. So if I had a table for trucks and a table for cars and I wanted a race table which would have a car or truck along with information regarding a race record as in date of race, name of race, etc... so essentially it would look like.

Tables
truck(T#, engine, wheels, driver)
car(C#, engine, wheels, driver)
race(r#,Race Name, T# or C#?, race date, location)

This is just an example I made up but my project has a similar problem in which I can't figure out how subtypes of a type could be handled.
Reply With Quote
  #2 (permalink)  
Old 12-05-10, 05:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by CrimsonK View Post
Is this bad that I came up with the same amount of tables as I did entities?
no, usually you have more tables than entities (e.g. a relationship table between two entity tables, to implement a many-to-many relationship)

Quote:
Originally Posted by CrimsonK View Post
How would you handle creating a table in which one of it's columns needs to refer to two similar but different tables.
using a supertype/subtype structure

Tables
vehicle (vehicle_no PK, driver) -- supertype
truck (vehicle_no PK/FK, engine, wheels, other truck columns) -- subtype
car (vehicle_no PK/FK, engine, wheels, other car columns) -- subtype
race (race_no PK, race_name, vehicle_no FK, race_date, location)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-05-10, 12:03
CrimsonK CrimsonK is offline
Registered User
 
Join Date: Dec 2010
Posts: 2
alright. This leads to a couple other questions. How would you implement that into a select statement if they have the same primary key?

For my project though I'm making a database for review website. the thing is, is I might scrap it because I have the same amount of entities as tables.

because all the relationships are very simple and about the same such as a review to reviewer is made review. The only many to many relationship I have is that one platform such as xbox360 can have many games and one game can be on many platforms, but I don't see it to be necessary to make another table for that. But overall my design would work for a functional database though it has the same amount of tables as entities.

Now in all cases is having the same amount of tables as entities bad? if so i need to change this.

Last edited by CrimsonK; 12-05-10 at 12:03. Reason: added question
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On