I am trying to develope a db with Sql Server Management Studio.
Grandparent table
Resource
ResourceID_PK int
Project nvarchar(5)
Model nvarchr(15)
Parent table
Machine
MachineID_PK int
Model_UK nvarchar(15)
Type
Brand
EmptyWeight
Child tables
DumpTruck . Excavator Loader
DumpTruckID_PK ExcavatorID_PK Loader_ID int
Model_UK Model_UK Model_UK nvarchar(15)
Capacity Capacity Capacity
Model column is unique for whole db. I need to reach Capacity column from Grandparent table. Model column of each Child tables are unique since all machinery will have different Model like “CAT966”.
I need to use Grandparent Model column to read one of the Child table, which has the same Model.
I develope a c# project which inputs Model of the machine and will return capacity from the corresponding child table.
To join the tables, you will need ResourceID_PK in the Parent table and MachineID_PK in the Child tables. Then you can join the tables and reach the Capacity column from the Grandparent table.
EDIT
To get the Capacity based on Model, use this query:
(A small warning, I have not tested this query.)