I have an application where I have a generic object (table) called Hull. Each hull in the table is unique.
I have another object that has three hulls, but they are specifically the Port_Hull, Center_Hull and Starboard_Hull.
Rather than create a One to Many relationship, I was trying to create a one to one relationship for each one, but this results in numerous errors unless I make the relationship from Hull to Vessel one to many (which it is not). Any idea how I go about this, or should I abandon the concept and make the vessel to hull relationship one to many and deal with lists that always have three entries?
p.s. Using uniqueidentifiers as many users can be adding records while disconnected.
Hull Table
- HullID uniqueidentifier (primary key)
- plus bunch of hull data fields
Vessel Table
- VesselID uniqueidentifier (primary key)
- MainHullID uniqueidentifier (tried as key and non-key)
- PortHullID uniqueidentifier
- StarboardHullID uniqueidentifier
- plus bunch of Vessel data fields
You can solve this 1:1 in two different ways:
I would go for the first one. since it seems more natural to select a vessel and then find the associated hulls, and also ensures that each vessel has the 3 hulls required (assmining a non-null constraint on MainHull, PortHull, StarboardHull.)
EDIT: Seeing your comment, and given that vessels don’t need 3 hulls, then the second solution is also worth considering. If you need to add additional types of hull, you do this without changing your schema, since the hull type is not inferred from the field it is referenced, but named explicitly in the proposed ‘HullType’ field.