/*
SQLyog Community v13.3.0 (64 bit)
MySQL - 8.0.42-0ubuntu0.20.04.1 : Database - webrtc
*********************************************************************
*/



CREATE DATABASE /*!32312 IF NOT EXISTS*/`webrtc` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `webrtc`;

/*Table structure for table `admin_users` */


CREATE TABLE `admin_users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

/*Data for the table `admin_users` */

insert  into `admin_users`(`id`,`username`,`password`) values 
(1,'admin','123');

/*Table structure for table `hotel_tables` */


CREATE TABLE `hotel_tables` (
  `id` int NOT NULL AUTO_INCREMENT,
  `hotel_id` int NOT NULL,
  `table_number` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hotel_id` (`hotel_id`),
  CONSTRAINT `hotel_tables_ibfk_1` FOREIGN KEY (`hotel_id`) REFERENCES `hotels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

/*Data for the table `hotel_tables` */

insert  into `hotel_tables`(`id`,`hotel_id`,`table_number`) values 
(1,2,1),
(2,3,1),
(3,3,2),
(4,4,1);

/*Table structure for table `hotels` */


CREATE TABLE `hotels` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `latitude` decimal(10,8) NOT NULL,
  `longitude` decimal(11,8) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

/*Data for the table `hotels` */

insert  into `hotels`(`id`,`name`,`email`,`password`,`latitude`,`longitude`) values 
(2,'Example','mithunmts@gmail.com','123',10.77639200,76.18271800),
(3,'ABCD','abcd@abcd.com','123123',10.77639200,76.18271800),
(4,'Shaji','shaji@shaji.com','123123',10.77639200,76.18271800);

/*Table structure for table `receivers` */


CREATE TABLE `receivers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `hotel_id` int NOT NULL,
  `device_name` varchar(100) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `peer_id` varchar(255) DEFAULT NULL,
  `is_busy` tinyint(1) DEFAULT '0',
  `last_seen` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `peer_id` (`peer_id`),
  KEY `hotel_id` (`hotel_id`),
  CONSTRAINT `receivers_ibfk_1` FOREIGN KEY (`hotel_id`) REFERENCES `hotels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

/*Data for the table `receivers` */

insert  into `receivers`(`id`,`hotel_id`,`device_name`,`username`,`password`,`peer_id`,`is_busy`,`last_seen`) values 
(1,2,'DEV1','mts','123','78f9bc07-28dd-4199-8f83-4169edd6fbe3',0,'2025-08-06 23:12:06'),
(2,3,'rasheed','rasheed','123','8d7cc991-82a9-4402-8026-b46e92f40663',0,'2025-08-13 17:48:28'),
(3,4,'shaji','shaji','123123','df82fe4d-77f7-4de2-b9cc-4c882f0b8ec1',0,'2025-09-12 07:48:22');

