--
-- Host: localhost    Database: steplix
-- ------------------------------------------------------

USE `steplix`;


--
-- Table structure for table `attributes`
--

CREATE TABLE `attributes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `attributes`
--

INSERT INTO `attributes` VALUES (1,'fullname'),(2,'avatar'),(3,'email'),(4,'password'),(5,'address'),(6,'zipcode'),(7,'phone');

--
-- Table structure for table `device_brands`
--

CREATE TABLE `device_brands` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `device_brands`
--

INSERT INTO `device_brands` VALUES (1,'Samsung','2019-04-18 22:17:00'),(2,'Motorola','2019-04-18 22:17:00'),(3,'Apple','2019-04-18 22:17:00');

--
-- Table structure for table `device_screensizes`
--

CREATE TABLE `device_screensizes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `device_screensizes`
--

INSERT INTO `device_screensizes` VALUES (1,'1440×2560','2019-04-18 22:17:00'),(2,'750×1334','2019-04-18 22:17:00'),(3,'720×1280','2019-04-18 22:17:00');

--
-- Table structure for table `devices`
--

CREATE TABLE `devices` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_device_brand` int(10) unsigned NOT NULL,
  `id_device_screensize` int(10) unsigned NOT NULL,
  `description` varchar(128) NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `devices`
--

INSERT INTO `devices` VALUES (1,1,2,'Samsung S7','2019-04-18 22:17:01'),(2,1,1,'Samsung S8','2019-04-18 22:17:01'),(3,1,1,'Samsung S9','2019-04-18 22:17:01'),(4,3,1,'iPhone 8','2019-04-18 22:17:01');

--
-- Table structure for table `measurements`
--

CREATE TABLE `measurements` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_metric` int(10) unsigned NOT NULL,
  `id_unit` int(10) unsigned NOT NULL,
  `amount` decimal(16,4) unsigned NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `measurements`
--

INSERT INTO `measurements` VALUES (1,1,1,37.1200,'2019-04-18 22:17:01'),(2,1,1,36.2400,'2019-04-18 22:17:01'),(3,1,1,38.7100,'2019-04-18 22:17:01'),(4,1,1,35.2900,'2019-04-18 22:17:01'),(5,1,1,38.8100,'2019-04-18 22:17:01'),(6,1,1,37.4100,'2019-04-18 22:17:01'),(7,1,1,36.5600,'2019-04-18 22:17:01'),(8,1,1,37.0500,'2019-04-18 22:17:01');

--
-- Table structure for table `metrics`
--

CREATE TABLE `metrics` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `metrics`
--

INSERT INTO `metrics` VALUES (1,'humidity'),(2,'temperature'),(3,'precipitations'),(4,'voltage');

--
-- Table structure for table `organization_attributes`
--

CREATE TABLE `organization_attributes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_organization` int(10) unsigned NOT NULL,
  `id_attribute` int(10) unsigned NOT NULL,
  `description` varchar(256) NOT NULL,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `id_organization` (`id_organization`),
  KEY `id_attribute` (`id_attribute`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `organization_attributes`
--

INSERT INTO `organization_attributes` VALUES (1,1,1,'Acme Corporation',1,'2019-04-18 22:17:01',NULL),(2,1,5,'20833 Stevens Creek Blvd, Cupertino, CA 95014, USA',1,'2019-04-18 22:17:01',NULL),(3,1,7,'+1 (408) 996-1010',1,'2019-04-18 22:17:01',NULL),(4,2,1,'Globex Corporation',1,'2019-04-18 22:17:01',NULL),(5,2,5,'20955 Alves Dr, Cupertino, CA 95014, USA',1,'2019-04-18 22:17:01',NULL),(6,2,7,'+1 (408) 725-3707',1,'2019-04-18 22:17:01',NULL),(7,3,1,'Soylent Corp',1,'2019-04-18 22:17:01',NULL),(8,3,5,'20999 Stevens Creek Fwy, Cupertino, CA 95014, USA',1,'2019-04-18 22:17:01',NULL),(9,3,7,'+1 (408) 257-6884',1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `organization_products`
--

CREATE TABLE `organization_products` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_organization` int(10) unsigned NOT NULL,
  `id_product` int(10) unsigned NOT NULL,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_organization.id_product` (`id_organization`,`id_product`),
  KEY `id_product` (`id_product`),
  KEY `id_organization` (`id_organization`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `organization_products`
--

INSERT INTO `organization_products` VALUES (1,1,1,1,'2019-04-18 22:17:01',NULL),(2,1,2,1,'2019-04-18 22:17:01',NULL),(3,1,3,1,'2019-04-18 22:17:01',NULL),(4,2,1,1,'2019-04-18 22:17:01',NULL),(5,2,2,1,'2019-04-18 22:17:01',NULL),(6,3,1,1,'2019-04-18 22:17:01',NULL),(7,3,3,1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `organization_users`
--

CREATE TABLE `organization_users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_organization` int(10) unsigned NOT NULL,
  `id_user` int(10) unsigned NOT NULL,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_organization.id_user` (`id_organization`,`id_user`),
  KEY `id_organization` (`id_organization`),
  KEY `id_user` (`id_user`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `organization_users`
--

INSERT INTO `organization_users` VALUES (1,1,1,1,'2019-04-18 22:17:01',NULL),(2,1,2,1,'2019-04-18 22:17:01',NULL),(3,1,3,1,'2019-04-18 22:17:01',NULL),(4,2,4,1,'2019-04-18 22:17:01',NULL),(5,2,5,1,'2019-04-18 22:17:01',NULL),(6,3,6,1,'2019-04-18 22:17:01',NULL),(7,3,7,1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `organizations`
--

CREATE TABLE `organizations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `organizations`
--

INSERT INTO `organizations` VALUES (1,1,'2019-04-18 22:17:01',NULL),(2,1,'2019-04-18 22:17:01',NULL),(3,1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` VALUES (1,'owner'),(2,'admin'),(3,'editor'),(4,'readonly');

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `products`
--

INSERT INTO `products` VALUES (1,'Weather Station'),(2,'Smart Bulb'),(3,'Smart Lock'),(4,'Humidity Spear'),(5,'Accelerometer');

--
-- Table structure for table `units`
--

CREATE TABLE `units` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(128) NOT NULL,
  `unit` varchar(8) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `units`
--

INSERT INTO `units` VALUES (1,'percentage','%'),(2,'celsius','Cº'),(3,'millivolt','mV');

--
-- Table structure for table `user_attributes`
--

CREATE TABLE `user_attributes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_user` int(10) unsigned NOT NULL,
  `id_attribute` int(10) unsigned NOT NULL,
  `description` BINARY(32) NOT NULL,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `id_user` (`id_user`),
  KEY `id_attribute` (`id_attribute`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `user_attributes`
--

INSERT INTO `user_attributes` VALUES (1,1,1,'John Doe',1,'2019-04-18 22:17:01',NULL),(2,1,3,'john.doe@gmail.com',1,'2019-04-18 22:17:01',NULL),(3,1,4,'9959a1c23dcc98a7b3ca78dfd777d7ad',1,'2019-04-18 22:17:01',NULL),(4,2,1,'Mario Speedwagon',1,'2019-04-18 22:17:01',NULL),(5,2,3,'mario.speedwagon@gmail.com',1,'2019-04-18 22:17:01',NULL),(6,2,4,'fbbaad48686fa8f3a6e1d0c92b301da9',1,'2019-04-18 22:17:01',NULL),(7,3,1,'Anna Sthesia',1,'2019-04-18 22:17:01',NULL),(8,3,3,'anna.sthesia@gmail.com',1,'2019-04-18 22:17:01',NULL),(9,3,4,'433572aec18e8f74f4ddd2ba72b69144',1,'2019-04-18 22:17:01',NULL),(10,3,1,'Paul Molive',1,'2019-04-18 22:17:01',NULL),(11,3,3,'paul.molive@gmail.com',1,'2019-04-18 22:17:01',NULL),(12,3,4,'c4e3013d6faa2ebaf904a76140e7050e',1,'2019-04-18 22:17:01',NULL),(13,3,1,'Anna Mull',1,'2019-04-18 22:17:01',NULL),(14,3,3,'anna.mull@gmail.com',1,'2019-04-18 22:17:01',NULL),(15,3,4,'039ac5d5fb2ff5039e57a158a6080bed',1,'2019-04-18 22:17:01',NULL),(16,3,1,'Gail Forcewind',1,'2019-04-18 22:17:01',NULL),(17,3,3,'gail.forcewind@gmail.com',1,'2019-04-18 22:17:01',NULL),(18,3,4,'513a0fc87d6aa8625cc2b6b09a85563e',1,'2019-04-18 22:17:01',NULL),(19,3,1,'Paige Turner',1,'2019-04-18 22:17:01',NULL),(20,3,3,'paige.turner@gmail.com',1,'2019-04-18 22:17:01',NULL),(21,3,4,'b5bef18676056fea7f2e4b727bf8b91f',1,'2019-04-18 22:17:01',NULL),(22,3,1,'Bob Frapples',1,'2019-04-18 22:17:01',NULL),(23,3,3,'bob.frapples@gmail.com',1,'2019-04-18 22:17:01',NULL),(24,3,4,'4d1a3a7de62d988b6a0f00748c54c375',1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `user_permissions`
--

CREATE TABLE `user_permissions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_user` int(10) unsigned NOT NULL,
  `id_permission` int(10) unsigned NOT NULL,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_user.id_permission` (`id_user`,`id_permission`),
  KEY `id_user` (`id_user`),
  KEY `id_permission` (`id_permission`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `user_permissions`
--

INSERT INTO `user_permissions` VALUES (1,1,1,1,'2019-04-18 22:17:01',NULL),(2,2,2,1,'2019-04-18 22:17:01',NULL),(3,3,3,1,'2019-04-18 22:17:01',NULL),(4,4,1,1,'2019-04-18 22:17:01',NULL),(5,5,3,1,'2019-04-18 22:17:01',NULL),(6,6,1,1,'2019-04-18 22:17:01',NULL),(7,7,3,1,'2019-04-18 22:17:01',NULL);

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `users`
--

INSERT INTO `users` VALUES (1,1,'2019-04-18 22:17:01',NULL),(2,1,'2019-04-18 22:17:01',NULL),(3,1,'2019-04-18 22:17:01',NULL);


