Tables question ?

Discussion in 'Java' started by tomo, May 27, 2010.

  1. tomo

    tomo Guest

    I have 2 datatables. One(PROJECTION) with fields PROJECTION_ID,
    PROJECTION_COMPANY_NAME, and the second table(PROJECTION_VALUES) with fields
    PROJECTION_FK, YEAR_ONE, YEAR_TWO.
    Now, there is a big posibility that form on the web would need more then two
    years(YEAR_ONE,YEAR_TWO), let say four year's ? Is it better to add two more
    columns in the PROJECTION_VALUES table, or to
    create a third table(lookup) named for example PROJECTION_YEARS and than
    PROJECTION_VALUES will have FK to PROJECTION_YEARS, and a coulmn names for
    example PROJECTION_VALUE ?

    Thanks in advance.




    __________ Information from ESET NOD32 Antivirus, version of virus signature database 5149 (20100527) __________

    The message was checked by ESET NOD32 Antivirus.

    http://www.eset.com
    tomo, May 27, 2010
    #1
    1. Advertising

  2. tomo

    Tom Anderson Guest

    On Thu, 27 May 2010, tomo wrote:

    > I have 2 datatables. One(PROJECTION) with fields PROJECTION_ID,
    > PROJECTION_COMPANY_NAME, and the second table(PROJECTION_VALUES) with
    > fields PROJECTION_FK, YEAR_ONE, YEAR_TWO. Now, there is a big posibility
    > that form on the web would need more then two years(YEAR_ONE,YEAR_TWO),
    > let say four year's ? Is it better to add two more columns in the
    > PROJECTION_VALUES table, or to create a third table(lookup) named for
    > example PROJECTION_YEARS and than PROJECTION_VALUES will have FK to
    > PROJECTION_YEARS, and a coulmn names for example PROJECTION_VALUE ?


    This question is about databases, not java, so it should go to a databases
    group, not a java group. I've added a cross-post (with followup) to
    comp.databases.

    My answer would be that you definitely shouldn't add more columns to the
    projection_values table. In fact, you shouldn't even have two. I don't
    think i'd bother with a third table, though. I'd just do:

    create table projection (
    projection_id integer primary key,
    projection_company_name varchar(255) not null unique
    );

    create table projection_value (
    projection_id integer not null references projection,
    year integer not null,
    constraint projection_value_pk primary key (projection_id, year),
    projection_value whatever
    );

    That's simple, normalised, and likely to be fast for simple lookup-type
    queries ('find all projection values for the company called X', 'find the
    projection value for the company with ID Z in year Y').

    tom

    --
    the themes of time-travel, dreams, madness, and destiny are inextricably
    confused
    Tom Anderson, May 27, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pierre van Rooyen
    Replies:
    3
    Views:
    538
    Cor Ligthert
    May 21, 2004
  2. Neo Geshel

    SQL tables question

    Neo Geshel, Nov 17, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    573
    Al Reid
    Nov 18, 2005
  3. Peter Bassett
    Replies:
    3
    Views:
    912
    Augustus
    Aug 15, 2003
  4. Otuatail

    Tables within tables

    Otuatail, Jul 31, 2004, in forum: HTML
    Replies:
    7
    Views:
    483
  5. Chris Brat
    Replies:
    5
    Views:
    687
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
Loading...

Share This Page