· 8 years ago · Mar 16, 2018, 02:02 AM
1--
2-- Table structure for table `devices`
3--
4
5CREATE TABLE IF NOT EXISTS `devices` (
6 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
7 `user_id` int(10) unsigned NOT NULL,
8 `name` varchar(40) NOT NULL,
9 `model_id` int(10) unsigned NOT NULL,
10 `uid` varchar(255) NOT NULL,
11 `status` enum('active','unactive') NOT NULL DEFAULT 'unactive',
12 `secure_code` varchar(20) NOT NULL,
13 `activated` enum('Y','N') NOT NULL DEFAULT 'N',
14 PRIMARY KEY (`id`),
15 UNIQUE KEY `uid` (`uid`),
16 KEY `user_id` (`user_id`),
17 KEY `model_id` (`model_id`)
18) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
19
20-- --------------------------------------------------------
21
22--
23-- Table structure for table `device_models`
24--
25
26CREATE TABLE IF NOT EXISTS `device_models` (
27 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
28 `name` varchar(60) NOT NULL,
29 PRIMARY KEY (`id`),
30 UNIQUE KEY `name` (`name`)
31) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
32
33--
34-- Constraints for dumped tables
35--
36
37--
38-- Constraints for table `devices`
39--
40ALTER TABLE `devices`
41 ADD CONSTRAINT `devices_ibfk_2` FOREIGN KEY (`model_id`) REFERENCES `device_models` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;