· 10 years ago · Aug 22, 2016, 09:20 PM
1-- Host: localhost
2-- Generation Time: May 23, 2012 at 05:12 PM
3-- Server version: 5.5.22
4-- PHP Version: 5.3.10-1ubuntu3.1
5
6SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
7
8--
9-- Database: `nwss_client`
10--
11
12-- --------------------------------------------------------
13
14--
15-- Table structure for table `phidget_attach_log`
16--
17
18CREATE TABLE IF NOT EXISTS `phidget_attach_log` (
19 `id` int NOT NULL AUTO_INCREMENT KEY,
20 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
21 `pid` int(11) NOT NULL,
22 `serialnum` int(11) NOT NULL,
23 `isattached` tinyint(1) NOT NULL
24) ENGINE=InnoDB DEFAULT CHARSET=latin1;
25
26-- --------------------------------------------------------
27
28--
29-- Table structure for table `phidget_config`
30--
31
32CREATE TABLE IF NOT EXISTS `phidget_config` (
33 `serialnum` int(11) NOT NULL PRIMARY KEY,
34 `type` enum('digital', 'analog') NOT NULL,
35 `index` tinyint(4) NOT NULL,
36 `engine` enum('StableStateChange', 'ChangeLogger', 'BaselineStateSensor', 'BaselineStateAndChangeLogger') NOT NULL,
37 `datarate` smallint DEFAULT NULL,
38 `stable_after` float DEFAULT NULL,
39 `baseline` smallint DEFAULT null,
40 `tolerance` smallint DEFAULT null
41) ENGINE=InnoDB DEFAULT CHARSET=latin1;
42
43-- --------------------------------------------------------
44
45--
46-- Table structure for table `phidget_program_log`
47--
48
49CREATE TABLE IF NOT EXISTS `phidget_program_log` (
50 `id` int NOT NULL AUTO_INCREMENT KEY,
51 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
52 `pid` int(11) NOT NULL,
53 `message` text NOT NULL
54) ENGINE=InnoDB DEFAULT CHARSET=latin1;
55
56-- --------------------------------------------------------
57
58--
59-- Table structure for table `phidget_state_log`
60--
61
62CREATE TABLE IF NOT EXISTS `phidget_state_log` (
63 `id` int NOT NULL AUTO_INCREMENT KEY,
64 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
65 `pid` int(11) NOT NULL,
66 `serialnum` int(11) NOT NULL,
67 `type` enum('digital', 'analog') NOT NULL,
68 `index` tinyint(4) NOT NULL,
69 `is_on` tinyint(1) NOT NULL,
70 `processed` bool NOT NULL DEFAULT 0
71) ENGINE=InnoDB DEFAULT CHARSET=latin1;
72
73-- --------------------------------------------------------
74
75--
76-- Table structure for table `phidget_sensor_log`
77--
78
79
80CREATE TABLE IF NOT EXISTS `phidget_sensor_log` (
81 `id` int NOT NULL AUTO_INCREMENT KEY,
82 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
83 `pid` int(11) NOT NULL,
84 `serialnum` int(11) NOT NULL,
85 `index` tinyint(4) NOT NULL,
86 `value` int(11) NOT NULL,
87 `processed` bool NOT NULL DEFAULT 0
88) ENGINE=InnoDB DEFAULT CHARSET=latin1;
89
90
91
92-- --------------------------------------------------------
93
94--
95-- Views for seeing current status
96--
97
98-- This first one is just a helper. For some crazy reason, MySQL won't make
99-- a query that selects from a subselect into a view. So one must extract
100-- the subselect into its own view and then select from that.
101
102-- create view phidget_state_maxid as select max(id) id from phidget_state_log group by serialnum, input, `index`;
103-- create view phidget_state as select a.* from phidget_state_maxid b join phidget_state_log a on a.id = b.id;