Hi there.
Could someone please tell me how would I structure this excel table in sql?
Thx in advance
Ben
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ben erasmusPosted Oct 24, 2014, 8:09 AM
Wim SturkenboomPosted Oct 24, 2014, 12:31 AM
A single table can do the trick
tbl
Name
DMmin
DMmax
CPmin
CPmax
RUPmin
RUPmax
If DM, CP and RUP are the same objects with a different name, use two tables
tblName
PK
Name
tblValues
PK
FK (links to tblName)
Description (DM, CP, RUP)
Min
Max
If DM, CP and RUP are totally different objects, you need 4 tables
tblName
PK
Name
tblDM
PK
FK (links to tblName)
SomeOtherDataForDM
...
...
Min
Max
tblCP
PK
FK (links to tblName)
SomeOtherDataForCP
...
...
Min
Max
tblRUP
PK
FK (links to tblName)
SomeOtherDataForRUP
...
...
Min
Max
Note that PK (the primary key) can be the name; in which case FK will also be the name and you can remove PK from the above table design.
PK and FK link the different tables together.
For the multiple table approach, a select query can look like
select
tblName.*,
tblDM.Min,
tblDM.Max,
tblCP.Min,
tblCP.Max,
tblRUP.Min,
tblRUP.Max
from tblName
left join tblDM on tblName.PK=tblDM.FK
left join tblCP on tblName.PK=tblCP.FK
left join tblRUP on tblName.PK=tblRUP.FK