Skip to main content

Foreign key mapping is a proven technique for implementing a one-to-many relationship (not mandatory, i.e. 1 - 0..*). So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an one-to-one (not mandatory, i.e. 1 - 0..1).

This is a reasonable solution, if you are sure that the relationship shall not evolutionevolve to become one-to-many. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured and the parcel tracking number was issued by the carrier).

Foreign key mapping is a proven technique for implementing a one-to-many relationship (not mandatory, i.e. 1 - 0..*). So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an one-to-one (not mandatory, i.e. 1 - 0..1).

This is a reasonable solution, if you are sure that the relationship shall not evolution to become one-to-many. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured and the parcel tracking number was issued by the carrier).

Foreign key mapping is a proven technique for implementing a one-to-many relationship (not mandatory, i.e. 1 - 0..*). So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an one-to-one (not mandatory, i.e. 1 - 0..1).

This is a reasonable solution, if you are sure that the relationship shall not evolve to become one-to-many. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured and the parcel tracking number was issued by the carrier).

added 76 characters in body
Source Link
Christophe
  • 82.2k
  • 11
  • 136
  • 202

Foreign key mapping is a proven technique for implementing a one-to-many relationship (not mandatory, i.e. 1 - 0..*). So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an (optional) one-to-one (not mandatory, i.e. 1 - 0..1).

This is a reasonable solution, although it makes futureif you are sure that the relationship shall not evolution to become one-to-many difficult. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured, or and the parcel tracking number was issued by the carrier).

Foreign key mapping is a proven technique for implementing a one-to-many relationship. So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an (optional) one-to-one.

This is a reasonable solution, although it makes future evolution to one-to-many difficult. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured, or the parcel tracking number was issued by the carrier).

Foreign key mapping is a proven technique for implementing a one-to-many relationship (not mandatory, i.e. 1 - 0..*). So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an one-to-one (not mandatory, i.e. 1 - 0..1).

This is a reasonable solution, if you are sure that the relationship shall not evolution to become one-to-many. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured and the parcel tracking number was issued by the carrier).

Source Link
Christophe
  • 82.2k
  • 11
  • 136
  • 202

Foreign key mapping is a proven technique for implementing a one-to-many relationship. So having a foreign key in shipment_data that refers to shipment's primary key shipment.id would allow no, one, or many shipment_data for a specific shipment.

Using the foreign key as a primary key is possible. It requires you to first create the a shipment then the shipment_data reusing the same id, and it structurally constrains the relationship to an (optional) one-to-one.

This is a reasonable solution, although it makes future evolution to one-to-many difficult. It also works in case shipment_data creation could be delayed (for example if the shipment is first planned, and shipment_data would only be filled once the final package weight was measured, or the parcel tracking number was issued by the carrier).