Re: database design

From: Jan.Hidders <>
Date: 7 May 2002 21:49:59 +0200
Message-ID: <3cd82fe7$>

auddog ( wrote:
: i have a newbie question that i have tried to work out but don't
: understand how to make it work.

The trick is to press the character key and the shift key at the same time. :-) If you don't take the time to format you question properly, why do you think other people will take the time to answer you properly?

: here goes:
: table1 - project
: id
: name
: address
: table2 - construction
: id
: name
: table3 - project-construction
: id
: project_id
: contsruction_id
: the first table is project for project name as well as a job id, which is
: auto_incr. when i create a new job. the second table is construction type
: - ie - metal, wood, etc. the third table is combination table of the
: previous two tables. my question is how do i populate the last table when
: i'm creating a new job, since i don't know the id until after auto_incr.
: has given it a number.

My first advice would be not to use auto-increment fields. They rarely have any real meaning for the user, make transferring your data to another DBMS with another numbering scheme harder, and often make the modeler forget to look for the "real" primary key of the table. So unless you are sure that they save a lot of space or make your implementation faster, don't use them.

Anyway, if you really want them you can first insert the project and the look up it's id by selecting the project with the right name (assuming that every project has a unique name). You can do the same for construction and then you now the id's for the tupel in project-construction.

  • Jan Hidders
Received on Tue May 07 2002 - 21:49:59 CEST

Original text of this message