title: SQL - Storing values that have dynamic properties and constraints
body: <p>I'm not sure if what I'm attempting to do is simply incorrect/impossible or if there is an easier way and that I'm missing the point.</p>
  
  <p>I'm using SQL Server 2012 </p>
  
  <p>What I would like to do is have a table that can store rows with values relating to stored properties in another table. Basically, key value pair. The thing is, I would like to determine which key values can be used by which entities.</p>
  
  <p>For example,
  I would like one table listing various companies, another to store 'files' created for each company - this is used to store historical information, another listing various production departments(stages in production), another listing production figures(KGs, Units, etc), and one listing the actual production capture against these figures for each month. There are also tables in place to show which production departments can use which production figures as well as which company has which production departments.</p>
  
  <p>Some of the companies have the same stages in production as well as additional stages that the others don't. </p>
  
  <p>These figures are captured on a monthly basis ONLY, so I have a table describing all the months of a year.</p>
  
  <p>Each production department may have similar types of recordings to be captured, though they don't all have the same production readings.</p>
  
  <p>Here's a link to a graphical representation of the table layouts:
  <a href="http://tinypic.com/r/30a51mx/8" rel="nofollow">http://tinypic.com/r/30a51mx/8</a>
  ..</p>
  
  <hr>
  
  <p>My end result is to auto-populate / update the table with newly added figures as the user enters this section of the program (by passing through the FileID), and to allow the user to edit this using a datagridview (or atleast select a value to be edited from the datagridview)</p>
  
  <p>I will then need to write reports later on that will need to pivot on this information.</p>
  
  <hr>
  
  <p>Any help or suggestions would be greatly appreciated.</p>
  
  <p>Thanks</p>