Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a view based on column metadata
    primarykey
    data
    text
    <p>Let's assume two tables: TableA holds various data measurements from a variety of stations. TableB holds metadata, about the columns used in TableA.</p> <p>TableA has:</p> <pre><code>stationID int not null, pk entryDate datetime not null, pk waterTemp float null, waterLevel float null ...etc </code></pre> <p>TableB has:</p> <pre><code>id int not null, pk, autoincrement colname varchar(50), unit varchar(50) ....etc </code></pre> <p>So for example, one line of data from tableA reads:</p> <pre><code>1 | 2013-01-01 00:00 | 2.4 | 3.5 </code></pre> <p>two lines from tableB read:</p> <pre><code>1| waterTemp | celcius 2| waterLevel | meters </code></pre> <p>This is a simplified example. In truth, tableA might hold close to 20 different data columns, and table b has close to 10 metadata columns.</p> <p>I am trying to design a view which will output the results like this:</p> <pre><code>StationID | entryDate | water temperature | water level | 1 | 2013-01-01 00:00 | 2.4 celcius | 3.5 meters | </code></pre> <p>So two questions:</p> <ol> <li>Other than specifying subselects from TableB (..."where colname='XXX'") for each column, which seems horribly insufficient (not to mention...manual :P ), is there a way to get the result I mentioned earlier with automatic match on colname? </li> <li>I have a hunch that this might be bad design on the database. Is it so? If yes, what would be a more optimal design? (Bear in mind the complexity of the data structure I mentioned earlier)</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload