Create Recording Tables in MySQL

The SQL below creates your recording tables.

Replace the word 'Recordings' with your preferred table name, but please leave the '_lookup' and '_data' extensions.


CREATE TABLE IF NOT EXISTS `recordings_data` (
  `measurement` bigint(20) NOT NULL,
  `stamp` datetime NOT NULL,
  `value` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 CREATE TABLE IF NOT EXISTS `recordings_lookup` (
  `name` varchar(80) NOT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 CREATE VIEW rec AS 
   SELECT recordings_lookup.name AS measurement,
      recordings_data.stamp AS stamp,
      recordings_data.value AS value
    FROM (recordings_lookup 
      JOIN recordings_data ON
        (recordings_data.measurement = recordings_lookup.id))