Home » RDBMS Server » Server Administration » DB´s Models...
DB´s Models... [message #373814] Mon, 14 May 2001 08:32 Go to next message
Otávio
Messages: 6
Registered: April 2001
Junior Member
Hello there,

What´s the better Relation´s Modeling?

1)

|¯¯¯¯¯¯¯¯¯|
|Master_id| record id used like key in relation rules.
|---------|
|pkfield1 |\
|pkfield2 |--> Unique index... (simulating primary key)
|pkfield3 |/
|field1 |
|fieldn |
¯¯¯¯|¯¯¯¯
|
/|\
|¯¯¯¯¯¯¯¯¯|
|Detail_id|
|---------|
|Mater_Id |--> Foreign Key
|field1 |
|fieldn |
¯¯¯¯¯¯¯¯¯

2)

|¯¯¯¯¯¯¯¯¯|
|pkfield1 |\
|pkfield2 |--> primary key
|pkfield3 |/
|---------|
|field1 |
|fieldn |
¯¯¯¯|¯¯¯¯
|
/|\
|¯¯¯¯¯¯¯¯¯|
|Detail_id|
|---------|
|fkfield1 |\
|fkfield2 |--> Foreign Key
|fkfield3 |/
|field1 |
|fieldn |
¯¯¯¯¯¯¯¯¯

thanks so much...

Otávio
Re: DB´s Models... [message #373823 is a reply to message #373814] Mon, 14 May 2001 14:00 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
Both will work fine. Conceder these pros and cons though:
A.) From relational theory, you may not edit a PK's value. Also a PK may never be null. On the other hand, the composite Alternate Key may be null. For any record in the parent table having the Alt Key null, that record can't have child records. The Alt Key may be edited on the parent table (because it's a unique constraint or has a unique index on it), so that allows the relatioship to be transferable on the parent side.

The disadvantage of having the composite key on the child table is that you get a proliferation of fields on that table. This becomes more messy for each additional level. The advantage though, is that you can avoid navigating through each table to get to the top level, as the top level table's key already carried to the lowest level of child table. ( I assume pkfield1-3 are PK's of some top level tables)
Previous Topic: Masking special characters in SQLPLUS
Next Topic: Masking special characters in SQLPLUS
Goto Forum:
  


Current Time: Mon Dec 23 10:35:21 CST 2024