Results 1 to 3 of 3
  1. #1
    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.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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 13:03. Reason: added question

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •