sql server - SQL - complicated link table, no simple solution -


i working on project has relatively complicated data structure, , bit stumped following situation:

the db has various tables represent glazing unit* components (glass pane, coating, blind) , each 1 of these components has spectra. (* glazing unit - think double/triple glazing glass unit) have 1 spectra table per component table, , there simple fk relationship, follows:

tbl_glasspane    1 -- many   tbl_glasspane_spectra -------------                ------------- + id                         + glasspane_id   glasspanename              + wavelength   typeid etc.                  value 

where glasspaneid primary key in glasspane, , glasspaneid/wavelength composite primary key in tbl_spectra.

this works fine, need 1 tbl_xxx_spectra each component table.

the solution have 1 spectra table each of component tables reference, therein lies problem - how arbitrary number of component tables reference 1 spectra table?

my initial solution was:

tbl_spectra          tbl_spectraindex    tbl_glasspane       tbl_coating ---------------      ---------------     -------------       ------------- + spectraindex_id    + id                + id                + id + wavelength                               spectraindex_id     spectraindex_id   value 

so explanation...

tbl_spectraindex table contains 1 identity column. tbl_spectra has fk relationship between id tbl_spectraindex , spectraindex_id, , 1 part of composite pk tbl_spectra. tbl_glasspane , tbl_coating have fk relationship tbl_spectraindex.

is sensible solution?

in kind of cases better use de-normalized schema. use 1 single spectra table 2 fields: 1 int store kind of object (table) spectra belongs to. other int link table id. in cases spectra table linked multiple tables same field. tend example address table. in database have many objects need have 1 or more address object asociated, while every address has same fields. create single address table, 2 field mention early, 1 represent kind of object represent, , 1 link actual object.

also have consider putting glazing tables 1 single big table? hope helps you.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -