![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have three tables with a relationship I've never worked with before. Can anyone suggest/comment on the best way to create a third normal form relationship between these tables? The tables basically are: TRAIN (TRAIN_ID and 15 columns about train specs, etc) TRUCK (TRUCK_ID and 12 columns about truck specs, etc) TRANSPORTATION_ITEM This table has, among others, two columns, TRUCK_ID and TRAIN_ID. If the truck column is used there can be no data in the train column and vice versa. This relationship seems denormalized to me, but I don't remember how to normalize it. Does anyone know the correct name for this kind of relationship? thanks! |
#3
| |||
| |||
|
|
I have three tables with a relationship I've never worked with before. Can anyone suggest/comment on the best way to create a third normal form relationship between these tables? The tables basically are: TRAIN (TRAIN_ID and 15 columns about train specs, etc) TRUCK (TRUCK_ID and 12 columns about truck specs, etc) TRANSPORTATION_ITEM This table has, among others, two columns, TRUCK_ID and TRAIN_ID. If the truck column is used there can be no data in the train column and vice versa. This relationship seems denormalized to me, but I don't remember how to normalize it. Does anyone know the correct name for this kind of relationship? |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I have three tables with a relationship I've never worked with before. Can anyone suggest/comment on the best way to create a third normal form relationship between these tables? The tables basically are: TRAIN (TRAIN_ID and 15 columns about train specs, etc) TRUCK (TRUCK_ID and 12 columns about truck specs, etc) TRANSPORTATION_ITEM This table has, among others, two columns, TRUCK_ID and TRAIN_ID. If the truck column is used there can be no data in the train column and vice versa. This relationship seems denormalized to me, but I don't remember how to normalize it. Does anyone know the correct name for this kind of relationship? thanks! |
#7
| |||
| |||
|
|
I think there are a couple of ways you can go here. First is an assessment of what the business logic behind the TRANSPORTATION_ITEM table is. If it simply for output for the interface then move the business logic up into code. If that is not possible, or there is truly data that needs to be saved for another purpose, the the other route would be to add the TRANSPORTATION_ITEM id to the truck and train table. That should give you the normalization you require and reduce the NULL fields in the TRANSPORTATION_ITEM table which is what it appears you are really after. Then your query can join the from the train or truck table to the TRANSPORTATION_ITEM table. |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
This is the time when I mention that I purchased Joe Celko's "SQL For Smarties" several years ago and felt it was a great companion for learning standard SQL theory. I recommend the book for everyone who wants to take it to the next level. |
!!![]() |
| Thread Tools | |
| Display Modes | |
| |