Is it common practice to split the ids between many tables?

Example

+---------------------------+
| load                      | 
+---------------------------+
| load_id                   |
|                           |
+---------------------------+
      |              |
+-----------+ +-------------+
| load_plane| | load_truck  | 
+-----------+ +-------------+
| plane_id  | | truck_id    |
| load_id   | | load_id     |   
|           | |             |
+-----------+ +-------------+
      |              |
+-----------+ +-------------+
| plane     | | truck       | 
+-----------+ +-------------+
| plane_id  | | truck_id    |
|           | |             |   
|           | |             |
+-----------+ +-------------+

The load_id is made up of many product. It can be shipped by plain, train, bus, truck or spaceship oh ya, why not boat too. Just wondering what other peoples thoughts are on this.

有帮助吗?

解决方案

In this case you have many to many Relationships between load and plane, load and truck, load and boat. I think its better if you use some type column to identify transport type. So you can do it using 3 tables now.

+---------------------------+
| load                      | 
+---------------------------+
| load_id                   |
|                           |
+---------------------------+

+-------------+
| transport   |
+-------------+
| id          |
| type        |  
|             |
+-------------+

+---------------------------+
| load_transport            | 
+---------------------------+
| load_id                   |
| transport_id              |
+---------------------------+
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top