Originally posted by Raj Ohadi:
originally posted it in a wrong place, just found this forum --
In many document, it is recommeded to use unique system generated id as the PK for a table, for example
CD (id, author, title)
Track (id, cd_id, name, length)
"Track" tables contains a"cd_id" to refer to "CD" table. As a newbie, I have a few questions, please bear with me --
1. Create table. Suppose I use Oracle, when I create tables, besides theses two tables, do I have to manually create any other table in order to make these "id" be generated ?
Originally posted by Raj Ohadi:
2. Insert data -- Supose tables are created, if I want to do a regular insert of a row for Track, when I write my SQL, how do I know what's the "id" and "cd_id" ? Normally I just do "INSERT INTO TRACK VALUES("Gone with wind", 200)", but will this still work in this scenario ??
Originally posted by Raj Ohadi:
3. REgular SQL query, as an application user I have no idea about the value of "id" and "cd_id" for rows in the tables, so does the regular query
"SELECT * from CD, TRACK where CD.id = TRACK.cd_id and CD.arthor = "Steve""
still work (i.e. still query by regular attributes and just use the unique id for joining) ?
Thanks.
Originally posted by Raj Ohadi:
Paul,
bear with me for one more stupid question -- TRACK table includes "cd_id", when I actually insert a row to TRACK, what I know is "name" and "length", and the "author" who publishes the CD, but I do NOT know that "cd_id" assciated with that "author". So when I insert into TRACK table how do I handle the value of "cd_id", should I first "select cd_id from CD where author = 'steve'", then use this value for "cd_id" when I do insert for TRACK ? Sounds not convenient, any good way to handle it ?
Thanks.