Home » SQL & PL/SQL » SQL & PL/SQL » data model design
data model design [message #222604] Mon, 05 March 2007 10:57 Go to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
I am confused with the data model design .

I have a table called layout

table- Layout_definition
columns- layout_definition_id ,template_jsp,name

I need properties for the layout_definitions

So I created a table called Layout_properties

table- layout_properties
columns- layout_property_id ,name,jsp

Now one layout definition might have one or more layout properties .
To establish this relation

should I create a new table like
table -layout_definition_properties
columns layout_definition_id(FK) , layout_property_id(FK)

(here there is one to many relation one layout_definition_id might have several layout_properties )


or in the layout_properties table add a new column layout_definition_id which is a FK from table Layout_definition

which is better approach ?
Re: data model design [message #222629 is a reply to message #222604] Mon, 05 March 2007 12:46 Go to previous messageGo to next message
dude4084
Messages: 221
Registered: March 2005
Location: Mux
Senior Member
1st approach.i.e
should I create a new table like
table -layout_definition_properties
columns layout_definition_id(FK) , layout_property_id(FK)


Why not 2nd approach? because there will be data retendency.
Re: data model design [message #222631 is a reply to message #222604] Mon, 05 March 2007 12:48 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
It depends.
If a property can be owned by many layouts and a layout is made of many properties, then we call it a many to many relationship.
This requires an intermediate table.
If, like you suggest, a property can only be owned by one layout, it is called a one to many relationship, in which case no intermediate table is needed, but a simple foreign key will do.

By the way, it is good practice not to repeat the tablename in your column names. So just name the id columns ID. Only if they are foreign key columns, you use the tablename (or rather 3- or 4 letter alias) of the original table.

[Updated on: Mon, 05 March 2007 12:49]

Report message to a moderator

Previous Topic: URGENT PLS. HELP
Next Topic: SQL functionality by Oracle Version
Goto Forum:
  


Current Time: Sun Dec 04 18:29:34 CST 2016

Total time taken to generate the page: 0.08297 seconds