blob_id
stringlengths 40
40
| language
stringclasses 1
value | repo_name
stringlengths 5
133
| path
stringlengths 3
276
| src_encoding
stringclasses 33
values | length_bytes
int64 23
9.61M
| score
float64 2.52
5.28
| int_score
int64 3
5
| detected_licenses
listlengths 0
44
| license_type
stringclasses 2
values | text
stringlengths 23
9.43M
| download_success
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
70887bf950c386a849e9667122bcda7cb364ae71
|
SQL
|
GregoryOrd/CPSC471
|
/DATABASE_BACKUP.sql
|
UTF-8
| 60,807
| 3.15625
| 3
|
[] |
no_license
|
-- MySQL dump 10.13 Distrib 8.0.19, for Win64 (x86_64)
--
-- Host: localhost Database: cpsc471_rental_system
-- ------------------------------------------------------
-- Server version 8.0.19
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `amenity`
--
DROP TABLE IF EXISTS `amenity`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `amenity` (
`name` varchar(45) NOT NULL,
`building_name` varchar(45) NOT NULL,
`description` varchar(300) DEFAULT NULL,
`fees` int DEFAULT NULL,
PRIMARY KEY (`name`,`building_name`),
KEY `FK_amenity_buildingname` (`building_name`),
CONSTRAINT `FK_amenity_buildingname` FOREIGN KEY (`building_name`) REFERENCES `building` (`building_name`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `amenity`
--
LOCK TABLES `amenity` WRITE;
/*!40000 ALTER TABLE `amenity` DISABLE KEYS */;
INSERT INTO `amenity` VALUES ('Treadmill Parking Lot','Scranton apartment 1','Features an outdoor array of treadmills for all your exercise needs.',0),('Waterslide & pool','Scranton apartment 2','a chill slide and pool.',5);
/*!40000 ALTER TABLE `amenity` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `apartment`
--
DROP TABLE IF EXISTS `apartment`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `apartment` (
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`num_floors` int DEFAULT NULL,
PRIMARY KEY (`apartment_num`,`building_name`),
KEY `FK_apartment_buildingname` (`building_name`),
CONSTRAINT `FK_apartment_buildingname` FOREIGN KEY (`building_name`) REFERENCES `building` (`building_name`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `apartment`
--
LOCK TABLES `apartment` WRITE;
/*!40000 ALTER TABLE `apartment` DISABLE KEYS */;
INSERT INTO `apartment` VALUES (100,'Scranton apartment 2',1),(101,'Scranton apartment 2',1),(102,'Scranton apartment 2',1),(103,'Scranton apartment 2',1),(200,'Scranton apartment 2',1),(201,'Scranton apartment 2',1),(202,'Scranton apartment 2',1),(203,'Scranton apartment 2',1),(300,'Scranton apartment 2',1),(301,'Scranton apartment 2',1),(420,'Scranton apartment 1',2),(421,'Scranton apartment 1',2),(422,'Scranton apartment 1',2),(423,'Scranton apartment 1',2),(424,'Scranton apartment 1',2),(425,'Scranton apartment 1',2);
/*!40000 ALTER TABLE `apartment` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `bathroom`
--
DROP TABLE IF EXISTS `bathroom`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bathroom` (
`room_num` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`has_bathtub` bit(1) DEFAULT NULL,
`has_shower` bit(1) DEFAULT NULL,
PRIMARY KEY (`room_num`,`apartment_num`,`building_name`),
KEY `FK_bathroom_apartmentnum` (`apartment_num`),
KEY `FK_bathroom_buildingname` (`building_name`),
CONSTRAINT `FK_bathroom_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `room` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_bathroom_buildingname` FOREIGN KEY (`building_name`) REFERENCES `room` (`building_name`) ON DELETE CASCADE,
CONSTRAINT `FK_bathroom_roomnum` FOREIGN KEY (`room_num`) REFERENCES `room` (`room_num`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `bathroom`
--
LOCK TABLES `bathroom` WRITE;
/*!40000 ALTER TABLE `bathroom` DISABLE KEYS */;
INSERT INTO `bathroom` VALUES (4,421,'Scranton apartment 1',_binary '\0',_binary '');
/*!40000 ALTER TABLE `bathroom` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `bedroom`
--
DROP TABLE IF EXISTS `bedroom`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bedroom` (
`room_num` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`num_beds` int DEFAULT NULL,
PRIMARY KEY (`room_num`,`apartment_num`,`building_name`),
KEY `FK_bedroom_apartmentnum` (`apartment_num`),
KEY `FK_bedroom_buildingname` (`building_name`),
CONSTRAINT `FK_bedroom_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `room` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_bedroom_buildingname` FOREIGN KEY (`building_name`) REFERENCES `room` (`building_name`) ON DELETE CASCADE,
CONSTRAINT `FK_bedroom_roomnum` FOREIGN KEY (`room_num`) REFERENCES `room` (`room_num`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `bedroom`
--
LOCK TABLES `bedroom` WRITE;
/*!40000 ALTER TABLE `bedroom` DISABLE KEYS */;
INSERT INTO `bedroom` VALUES (2,421,'Scranton apartment 1',1);
/*!40000 ALTER TABLE `bedroom` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `bill`
--
DROP TABLE IF EXISTS `bill`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bill` (
`clientID` int NOT NULL,
`billID` int NOT NULL,
`payment_type` varchar(45) DEFAULT NULL,
`payment_date` date DEFAULT NULL,
PRIMARY KEY (`clientID`,`billID`),
CONSTRAINT `FK_bill_clientID` FOREIGN KEY (`clientID`) REFERENCES `client` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `bill`
--
LOCK TABLES `bill` WRITE;
/*!40000 ALTER TABLE `bill` DISABLE KEYS */;
INSERT INTO `bill` VALUES (5,1,NULL,NULL),(6,2,NULL,NULL);
/*!40000 ALTER TABLE `bill` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `building`
--
DROP TABLE IF EXISTS `building`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `building` (
`building_name` varchar(45) NOT NULL,
`landlordID` int DEFAULT NULL,
`property_manager_id` int DEFAULT NULL,
`city` varchar(45) DEFAULT NULL,
`province` varchar(45) DEFAULT NULL,
`postal_code` varchar(45) DEFAULT NULL,
`street_address` varchar(45) DEFAULT NULL,
PRIMARY KEY (`building_name`),
KEY `FK_building_landlordID` (`landlordID`),
KEY `FK_building_propmngrID` (`property_manager_id`),
CONSTRAINT `FK_building_landlordID` FOREIGN KEY (`landlordID`) REFERENCES `landlord` (`employeeID`) ON DELETE SET NULL,
CONSTRAINT `FK_building_propmngrID` FOREIGN KEY (`property_manager_id`) REFERENCES `property_manager` (`employeeID`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `building`
--
LOCK TABLES `building` WRITE;
/*!40000 ALTER TABLE `building` DISABLE KEYS */;
INSERT INTO `building` VALUES ('Scranton apartment 1',2,4,'Scranton','Pennsylvania','T4k-0T1','somewhere blvd'),('Scranton apartment 2',2,4,'Scranton','Pennsylvania','T4k-0T2','somewhere else blvd');
/*!40000 ALTER TABLE `building` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `client`
--
DROP TABLE IF EXISTS `client`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client` (
`userID` int NOT NULL,
`registration_date` date DEFAULT NULL,
`contract_type` varchar(45) DEFAULT NULL,
PRIMARY KEY (`userID`),
CONSTRAINT `FK_userID` FOREIGN KEY (`userID`) REFERENCES `user` (`userID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `client`
--
LOCK TABLES `client` WRITE;
/*!40000 ALTER TABLE `client` DISABLE KEYS */;
INSERT INTO `client` VALUES (5,'2015-03-23','2 year'),(6,'2018-11-11','5 years'),(7,'2018-11-11','1 year'),(8,'2018-11-11','3 years'),(9,'2018-11-11','1 year'),(10,'2018-11-11','2 years'),(11,'2010-04-05','6 years'),(12,'2018-11-11','1 year'),(13,'2020-01-04','2 year'),(14,'2014-08-11','1 year'),(15,'2015-12-01','3 years'),(16,'2018-11-11','1 year');
/*!40000 ALTER TABLE `client` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `credit_card`
--
DROP TABLE IF EXISTS `credit_card`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `credit_card` (
`clientID` int NOT NULL,
`card_number` varchar(45) DEFAULT NULL,
PRIMARY KEY (`clientID`),
CONSTRAINT `FK_card_clientID` FOREIGN KEY (`clientID`) REFERENCES `client` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `credit_card`
--
LOCK TABLES `credit_card` WRITE;
/*!40000 ALTER TABLE `credit_card` DISABLE KEYS */;
INSERT INTO `credit_card` VALUES (5,'5411168155836494'),(6,'5219319689255354'),(7,'4024007125075241'),(8,'3529926755691708'),(9,'5442331195445477'),(10,'6761580354630235');
/*!40000 ALTER TABLE `credit_card` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `dependant`
--
DROP TABLE IF EXISTS `dependant`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `dependant` (
`userID` int NOT NULL,
`client_dependee` int NOT NULL,
`is_under_eighteen` bit(1) DEFAULT NULL,
PRIMARY KEY (`userID`),
KEY `FK_dep_clientID` (`client_dependee`),
CONSTRAINT `FK_dep_clientID` FOREIGN KEY (`client_dependee`) REFERENCES `client` (`userID`),
CONSTRAINT `FK_dep_userID` FOREIGN KEY (`userID`) REFERENCES `user` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `dependant`
--
LOCK TABLES `dependant` WRITE;
/*!40000 ALTER TABLE `dependant` DISABLE KEYS */;
INSERT INTO `dependant` VALUES (17,15,_binary '\0'),(18,13,_binary '');
/*!40000 ALTER TABLE `dependant` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `district_manager`
--
DROP TABLE IF EXISTS `district_manager`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `district_manager` (
`employeeID` int NOT NULL,
`district_name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`employeeID`),
CONSTRAINT `FK_dstrctmngr_employeeID` FOREIGN KEY (`employeeID`) REFERENCES `employee` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `district_manager`
--
LOCK TABLES `district_manager` WRITE;
/*!40000 ALTER TABLE `district_manager` DISABLE KEYS */;
INSERT INTO `district_manager` VALUES (1,'Scranton Branch');
/*!40000 ALTER TABLE `district_manager` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `employee`
--
DROP TABLE IF EXISTS `employee`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `employee` (
`userID` int NOT NULL,
`hiring_manager` int DEFAULT NULL,
`hire_date` date NOT NULL,
`termination_date` date DEFAULT NULL,
`salary` int DEFAULT NULL,
`house_number` int DEFAULT NULL,
`street` varchar(45) DEFAULT NULL,
`city` varchar(45) DEFAULT NULL,
`province` varchar(45) DEFAULT NULL,
`postal_code` varchar(45) DEFAULT NULL,
PRIMARY KEY (`userID`),
KEY `FK_emp_hmngrID` (`hiring_manager`),
CONSTRAINT `FK_emp_hmngrID` FOREIGN KEY (`hiring_manager`) REFERENCES `district_manager` (`employeeID`) ON DELETE SET NULL,
CONSTRAINT `FK_emp_userID` FOREIGN KEY (`userID`) REFERENCES `user` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `employee`
--
LOCK TABLES `employee` WRITE;
/*!40000 ALTER TABLE `employee` DISABLE KEYS */;
INSERT INTO `employee` VALUES (1,1,'2009-03-17',NULL,45001,69,'Jan Way','Scranton','Pennsylvania','T4L-Q4L'),(2,NULL,'2010-09-23',NULL,45000,69,'Rose Grove','Scranton','Pennsylvania','T4Lf4L'),(3,1,'2012-09-23',NULL,35000,69,'Spark Wood','Scranton','Pennsylvania','G84-f3L'),(4,1,'2012-09-23',NULL,35000,69,'Spark Wood','Scranton','Pennsylvania','G84-f3L'),(5,1,'2012-09-23',NULL,35000,69,'mennonite beet farm','Scranton','Pennsylvania','G84-f3L');
/*!40000 ALTER TABLE `employee` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `kitchen`
--
DROP TABLE IF EXISTS `kitchen`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `kitchen` (
`room_num` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`num_sinks` int DEFAULT NULL,
`counter_top_type` varchar(45) DEFAULT NULL,
PRIMARY KEY (`room_num`,`apartment_num`,`building_name`),
KEY `FK_kitchen_apartmentnum` (`apartment_num`),
KEY `FK_kitchen_builidingname` (`building_name`),
CONSTRAINT `FK_kitchen_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `room` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_kitchen_builidingname` FOREIGN KEY (`building_name`) REFERENCES `room` (`building_name`) ON DELETE CASCADE,
CONSTRAINT `FK_kitchen_room_num` FOREIGN KEY (`room_num`) REFERENCES `room` (`room_num`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `kitchen`
--
LOCK TABLES `kitchen` WRITE;
/*!40000 ALTER TABLE `kitchen` DISABLE KEYS */;
INSERT INTO `kitchen` VALUES (3,421,'Scranton apartment 1',1,'15');
/*!40000 ALTER TABLE `kitchen` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `landlord`
--
DROP TABLE IF EXISTS `landlord`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `landlord` (
`employeeID` int NOT NULL,
`region` varchar(45) DEFAULT NULL,
PRIMARY KEY (`employeeID`),
CONSTRAINT `FK_landlord_empID` FOREIGN KEY (`employeeID`) REFERENCES `employee` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `landlord`
--
LOCK TABLES `landlord` WRITE;
/*!40000 ALTER TABLE `landlord` DISABLE KEYS */;
INSERT INTO `landlord` VALUES (2,'Scranton Region');
/*!40000 ALTER TABLE `landlord` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `living_room`
--
DROP TABLE IF EXISTS `living_room`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `living_room` (
`room_num` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`recommended_tv_size` int DEFAULT NULL,
PRIMARY KEY (`room_num`,`apartment_num`,`building_name`),
KEY `FK_livingroom_apartmentnum` (`apartment_num`),
KEY `FK_livingroom_buildingname` (`building_name`),
CONSTRAINT `FK_livingroom_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `room` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_livingroom_buildingname` FOREIGN KEY (`building_name`) REFERENCES `room` (`building_name`) ON DELETE CASCADE,
CONSTRAINT `FK_livingroom_roomnum` FOREIGN KEY (`room_num`) REFERENCES `room` (`room_num`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `living_room`
--
LOCK TABLES `living_room` WRITE;
/*!40000 ALTER TABLE `living_room` DISABLE KEYS */;
INSERT INTO `living_room` VALUES (1,421,'Scranton apartment 1',40);
/*!40000 ALTER TABLE `living_room` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `property_manager`
--
DROP TABLE IF EXISTS `property_manager`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `property_manager` (
`employeeID` int NOT NULL,
`years_experience` int DEFAULT NULL,
PRIMARY KEY (`employeeID`),
CONSTRAINT `FK_propmngr_empID` FOREIGN KEY (`employeeID`) REFERENCES `employee` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `property_manager`
--
LOCK TABLES `property_manager` WRITE;
/*!40000 ALTER TABLE `property_manager` DISABLE KEYS */;
INSERT INTO `property_manager` VALUES (4,2);
/*!40000 ALTER TABLE `property_manager` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `rents`
--
DROP TABLE IF EXISTS `rents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rents` (
`clientID` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
PRIMARY KEY (`clientID`,`apartment_num`,`building_name`),
KEY `FK_rents_apartmentnum` (`apartment_num`),
KEY `FK_rents_buildingname` (`building_name`),
CONSTRAINT `FK_rents_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `apartment` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_rents_buildingname` FOREIGN KEY (`building_name`) REFERENCES `apartment` (`building_name`) ON DELETE CASCADE,
CONSTRAINT `FK_rents_clientID` FOREIGN KEY (`clientID`) REFERENCES `client` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `rents`
--
LOCK TABLES `rents` WRITE;
/*!40000 ALTER TABLE `rents` DISABLE KEYS */;
INSERT INTO `rents` VALUES (5,421,'Scranton apartment 1','2012-09-28','2021-01-01'),(6,420,'Scranton apartment 1','2012-09-28','2021-01-01'),(7,422,'Scranton apartment 1','2012-09-28','2021-01-01'),(8,423,'Scranton apartment 1','2012-09-28','2021-01-01'),(9,424,'Scranton apartment 1','2012-09-28','2021-01-01'),(10,100,'Scranton apartment 2','2012-09-28','2021-01-01'),(11,101,'Scranton apartment 2','2012-09-28','2021-01-01'),(12,102,'Scranton apartment 2','2012-09-28','2021-01-01'),(13,200,'Scranton apartment 2','2012-09-28','2021-01-01'),(14,202,'Scranton apartment 2','2012-09-28','2021-01-01'),(15,300,'Scranton apartment 2','2012-09-28','2021-01-01'),(16,301,'Scranton apartment 2','2012-09-28','2021-01-01');
/*!40000 ALTER TABLE `rents` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `request`
--
DROP TABLE IF EXISTS `request`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `request` (
`requestID` int NOT NULL AUTO_INCREMENT,
`clientID` int DEFAULT NULL,
`description` varchar(45) DEFAULT NULL,
PRIMARY KEY (`requestID`),
KEY `FK_request_clientID` (`clientID`),
CONSTRAINT `FK_request_clientID` FOREIGN KEY (`clientID`) REFERENCES `client` (`userID`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `request`
--
LOCK TABLES `request` WRITE;
/*!40000 ALTER TABLE `request` DISABLE KEYS */;
INSERT INTO `request` VALUES (1,13,'Toby was sabotaged with marijuana left inside'),(2,8,'Kevin spilled chili'),(3,10,'Andy needs a new shelf for Cornell stuff');
/*!40000 ALTER TABLE `request` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `room`
--
DROP TABLE IF EXISTS `room`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `room` (
`room_num` int NOT NULL,
`apartment_num` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`num_windows` int DEFAULT NULL,
`flooring` varchar(45) DEFAULT NULL,
`room_size` int DEFAULT NULL,
PRIMARY KEY (`room_num`,`apartment_num`,`building_name`),
KEY `FK_room_apartmentnum` (`apartment_num`),
KEY `FK_room_buildingname` (`building_name`),
CONSTRAINT `FK_room_apartmentnum` FOREIGN KEY (`apartment_num`) REFERENCES `apartment` (`apartment_num`) ON DELETE CASCADE,
CONSTRAINT `FK_room_buildingname` FOREIGN KEY (`building_name`) REFERENCES `apartment` (`building_name`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `room`
--
LOCK TABLES `room` WRITE;
/*!40000 ALTER TABLE `room` DISABLE KEYS */;
INSERT INTO `room` VALUES (1,420,'Scranton apartment 1',1,'Vinyl',400),(1,421,'Scranton apartment 1',2,'Hardwood',500),(1,422,'Scranton apartment 1',2,'Hardwood',600),(2,421,'Scranton apartment 1',0,'Hardwood',500),(3,421,'Scranton apartment 1',1,'Hardwood',500),(4,421,'Scranton apartment 1',1,'Hardwood',200);
/*!40000 ALTER TABLE `room` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `service`
--
DROP TABLE IF EXISTS `service`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `service` (
`toolID` int NOT NULL,
`building_name` varchar(45) NOT NULL,
`technicianID` int NOT NULL,
`requestID` int NOT NULL,
`completed_date` date DEFAULT NULL,
PRIMARY KEY (`building_name`,`toolID`,`technicianID`,`requestID`),
KEY `FK_service_toolID` (`toolID`),
KEY `FK_service_technicianID` (`technicianID`),
KEY `FK_service_requestID` (`requestID`),
CONSTRAINT `FK_service_buildingname` FOREIGN KEY (`building_name`) REFERENCES `building` (`building_name`),
CONSTRAINT `FK_service_requestID` FOREIGN KEY (`requestID`) REFERENCES `request` (`requestID`),
CONSTRAINT `FK_service_technicianID` FOREIGN KEY (`technicianID`) REFERENCES `technician` (`employeeID`),
CONSTRAINT `FK_service_toolID` FOREIGN KEY (`toolID`) REFERENCES `tool` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `service`
--
LOCK TABLES `service` WRITE;
/*!40000 ALTER TABLE `service` DISABLE KEYS */;
INSERT INTO `service` VALUES (831,'Scranton apartment 1',3,2,'2020-06-25'),(327,'Scranton apartment 2',3,1,'2020-07-04'),(999,'Scranton apartment 2',3,3,'2020-03-01');
/*!40000 ALTER TABLE `service` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `technician`
--
DROP TABLE IF EXISTS `technician`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `technician` (
`employeeID` int NOT NULL,
`speciality` varchar(45) DEFAULT NULL,
PRIMARY KEY (`employeeID`),
CONSTRAINT `FK_technician_empID` FOREIGN KEY (`employeeID`) REFERENCES `employee` (`userID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `technician`
--
LOCK TABLES `technician` WRITE;
/*!40000 ALTER TABLE `technician` DISABLE KEYS */;
INSERT INTO `technician` VALUES (3,'Secretary skills');
/*!40000 ALTER TABLE `technician` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tool`
--
DROP TABLE IF EXISTS `tool`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tool` (
`id` int NOT NULL,
`type` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tool`
--
LOCK TABLES `tool` WRITE;
/*!40000 ALTER TABLE `tool` DISABLE KEYS */;
INSERT INTO `tool` VALUES (123,'plunger'),(327,'Flex Seal TM'),(583,'SUPER duct tape'),(690,'saw'),(691,'saw 2.0'),(831,'multimeter'),(999,'Matt\'s hangboard');
/*!40000 ALTER TABLE `tool` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user` (
`userID` int NOT NULL AUTO_INCREMENT,
`first_name` varchar(45) NOT NULL,
`last_name` varchar(45) NOT NULL,
`password_hash` varchar(45) NOT NULL,
PRIMARY KEY (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (1,'Michael','Scott','dsaf8s9fhasf'),(2,'Jim','Halpert','nzxnvsd0'),(3,'Pam','Beesly','sdf6923obw'),(4,'Dwight','Schrute','dsaf8s9fhasf'),(5,'Angela','Martin','sf9sa6dfa9syf'),(6,'Kelly','Kapoor','sfas8d0f1sc'),(7,'James','Bond','sadf923nd1'),(8,'Kevin','Malone','s-uvs-vjsnd'),(9,'Ryan','Howard','898hgwf'),(10,'Andy','Bernard','mdbf-e0'),(11,'Stanley','Hudson','sfs0r3hp'),(12,'Oscar','Martinez','sdyf2o3t2'),(13,'Toby','Flenderson','ofywtiwf'),(14,'Meredith','Palmer','sfd8uasro3u'),(15,'Phyllis','Vance','s-0dafm'),(16,'Creed','Bratton','sefasf903nslf'),(17,'Bob','Vance, VanceRefrigeration','xf90s8faf'),(18,'Sasha','Flenderson','hf43sf8faf');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping routines for database 'cpsc471_rental_system'
--
/*!50003 DROP PROCEDURE IF EXISTS `addAmenity` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addAmenity`(IN bName VARCHAR(45), IN aName VARCHAR(45), IN descrp VARCHAR(45), IN f int, OUT result int)
BEGIN
INSERT INTO amenity
VALUES (aName, bName, descrp, f);
SET result = 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addApartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addApartment`(IN bName VARCHAR(45), IN aNum int, IN nFloors int, OUT result int)
BEGIN
INSERT INTO apartment
VALUES (aNum, bName, nFloors);
SET result = 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addBuilding` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addBuilding`(IN bName VARCHAR(45), IN land_id int, IN prop_id int,
IN city VARCHAR(45), IN prov VARCHAR(45), IN postal VARCHAR(45),
IN street VARCHAR(45), OUT result int)
BEGIN
INSERT INTO building
VALUES (bName, land_id, prop_id, city, prov, postal, street);
SET result = 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addClient`(IN uid int, IN regDate datetime, IN contract VARCHAR(45))
BEGIN
INSERT INTO client
VALUES (uid, regDate, contract);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addDependant` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addDependant`(IN uid int, IN cid int, IN u18 bool)
BEGIN
INSERT INTO dependant
VALUES (uid, cid, u18);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addEmployee` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addEmployee`(IN userID int, IN man_id int, IN hire_date DATE, IN salary double, IN house_num int,
IN street VARCHAR(45), IN city VARCHAR(45), IN province VARCHAR(45), IN postal VARCHAR(45))
BEGIN
INSERT INTO employee (userID, hiring_manager, hire_date, salary, house_number, street, city, province, postal_code)
VALUES (userID, man_id, hire_date, salary, house_num, street, city, province, postal);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addUser` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `addUser`(IN fName VARCHAR(45), IN lName VARCHAR(45), IN pword VARCHAR(45))
BEGIN
INSERT INTO user (first_name, last_name, password_hash)
VALUES (fName, lName, pword);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `completeRequest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `completeRequest`(IN employee_id int, IN request_id int, IN building_name VARCHAR(45),
IN tool_id int, IN completion_date DATE)
BEGIN
INSERT INTO service
VALUES (tool_id, building_name, employee_id, request_id, completion_date);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getAmenities` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getAmenities`(IN bname VARCHAR(45))
BEGIN
SELECT *
FROM amenity
WHERE amenity.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getApartment` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getApartment`(IN anum int, IN bname VARCHAR(45))
BEGIN
SELECT apartment.num_floors, building.city, building.province, building.postal_code, building.street_address
FROM apartment
INNER JOIN building
ON apartment.building_name = building.building_name
WHERE apartment.apartment_num = anum
AND apartment.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getApartmentNums` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getApartmentNums`(IN bname VARCHAR(45))
BEGIN
SELECT apartment.apartment_num
FROM apartment
WHERE apartment.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getBuilding` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getBuilding`(IN bname VARCHAR(45))
BEGIN
SELECT *
FROM building
WHERE building.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getClient`(IN cid VARCHAR(45))
BEGIN
SELECT user.first_name, user.last_name, client.contract_type, client.registration_date, rents.apartment_num, rents.building_name, rents.start_date, rents.end_date
FROM client
INNER JOIN user
ON client.userID = user.userID
LEFT JOIN rents
ON client.userID = rents.clientID
WHERE client.userID = cid;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getClients` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getClients`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM client, user
WHERE client.userID = user.userID
AND user.userID = u_ID
AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDependants` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDependants`(IN cid VARCHAR(45))
BEGIN
SELECT dependant.userID, dependant.is_under_eighteen, user.first_name, user.last_name
FROM dependant
INNER JOIN user
ON dependant.userID = user.userID
WHERE dependant.client_dependee = cid;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDistrictManagers` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDistrictManagers`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM district_manager, user
WHERE district_manager.employeeID = user.userID
AND user.userID = u_ID
AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getLandlords` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getLandlords`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM landlord, user
WHERE landlord.employeeID = user.userID
AND user.userID = u_ID
AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getPropertyManagers` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getPropertyManagers`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM property_manager, user
WHERE property_manager.employeeID = user.userID
AND user.userID = u_ID
AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getRenter` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getRenter`(IN anum int, IN bname VARCHAR(45))
BEGIN
SELECT clientID
FROM rents
WHERE rents.apartment_num = anum
AND rents.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getRequestID` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getRequestID`(IN client_id int, IN descript VARCHAR(45))
BEGIN
SELECT requestID
FROM request
WHERE request.clientID = client_id AND request.description = descript
ORDER BY requestID desc
LIMIT 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getRooms` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getRooms`(IN anum int, IN bname VARCHAR(45))
BEGIN
SELECT room.*
FROM apartment
INNER JOIN room
ON apartment.building_name = room.building_name
AND apartment.apartment_num = room.apartment_num
WHERE apartment.apartment_num = anum
AND apartment.building_name = bname;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getTechnicians` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getTechnicians`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM technician, user
WHERE technician.employeeID = user.userID
AND user.userID = u_ID
AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getUserID` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getUserID`(IN fName VARCHAR(45), IN lName VARCHAR(45), IN pword VARCHAR(45))
BEGIN
SELECT userID FROM user
WHERE first_name = fName AND last_name = lName AND password_hash = pword
LIMIT 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getUsers` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getUsers`(p_hash VARCHAR(45), u_ID int)
BEGIN
SELECT *
FROM user
WHERE user.userID = u_ID AND user.password_hash = p_hash;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `listClients` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `listClients`(IN llid int)
BEGIN
SELECT client.userID
FROM client
INNER JOIN rents
ON client.userID = rents.clientID
INNER JOIN building
ON rents.building_name = building.building_name
WHERE building.landlordID = llid;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `listClientsFiltered` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `listClientsFiltered`(IN llid int, IN bnames VARCHAR(1024))
BEGIN
set @q = concat('SELECT client.userID
FROM client
INNER JOIN rents
ON client.userID = rents.clientID
INNER JOIN building
ON rents.building_name = building.building_name
WHERE building.landlordID = ', llid, '
AND building.building_name IN (', bnames, ')');
prepare stmt from @q;
execute stmt;
deallocate prepare stmt;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `payBill` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `payBill`(IN client_id int, IN bill_id int, IN pay_type VARCHAR(45), IN pay_date DATE)
BEGIN
UPDATE bill
SET bill.payment_type = pay_type, bill.payment_date = pay_date
WHERE bill.clientID = client_id AND bill.billID = bill_id;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `removeClient` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `removeClient`(IN cid int)
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE uid INT;
DECLARE curs CURSOR FOR
SELECT dependant.userID
FROM dependant
WHERE dependant.client_dependee = cid;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN curs;
delLoop: LOOP
FETCH curs INTO uid;
IF done THEN
LEAVE delLoop;
END IF;
DELETE FROM dependant WHERE userID = uid;
DELETE FROM user WHERE userID = uid;
END LOOP;
CLOSE curs;
DELETE FROM rents WHERE clientID = cid;
DELETE FROM bill WHERE clientID = cid;
DELETE FROM request WHERE clientID = cid;
DELETE FROM credit_card WHERE clientID = cid;
DELETE FROM client WHERE userID = cid;
DELETE FROM user WHERE userID = cid;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `setRents` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `setRents`(IN uid int, IN anum int, IN bname VARCHAR(45), IN sdate date, IN edate date)
BEGIN
INSERT INTO rents
VALUES (uid, anum, bname, sdate, edate);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `submitRequest` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `submitRequest`(IN client_id int, IN descript VARCHAR(45))
BEGIN
INSERT INTO request (clientID, description)
VALUES (client_id, descript);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `updatePassword` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = cp850 */ ;
/*!50003 SET character_set_results = cp850 */ ;
/*!50003 SET collation_connection = cp850_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `updatePassword`(IN p_hash VARCHAR(45), IN u_ID int, OUT result int)
BEGIN
UPDATE user
SET user.password_hash = p_hash
WHERE user.userID = u_ID;
SET result = 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-04-14 13:33:17
| true
|
0191c20c2e37b73affbb9d5f3973ded6b8caf505
|
SQL
|
GabrielC92/tpDatosC9gc
|
/tpDatosC9gc.sql
|
ISO-8859-1
| 1,071
| 3.78125
| 4
|
[] |
no_license
|
-- TP Mainpulacin y consulta de datos
-- Micro desafo 1
insert into genres (name, ranking, active)
values ('Investigacin', 13, 1);
update genres
set name = 'Investigacin Cientfica'
where name = 'Investigacin';
delete from genres
where name = 'Investigacin Cientfica';
select * from movies;
select first_name,last_name,rating from actors;
-- select titulo from series;
select title from series;
-- Micro desafo 2
select first_name,last_name from actors
where rating > 7.5;
select title,rating,awards from movies
where rating > 7.5
and awards > 2;
select title,rating from movies
order by rating;
-- Micro desafo 3
select title from movies
limit 3;
select * from movies
order by rating desc
limit 5;
select * from movies
order by rating desc
limit 5
offset 5;
select * from actors
limit 10;
select * from actors
limit 10
offset 20;
-- Micro desafo 4
select title,rating from movies
where title like 'Harry Potter%';
select * from actors
where first_name like 'Sam%';
select title from movies
where year (release_date)
between 2004 and 2008;
| true
|
b10ba1fbeb9e9eabead38af68fd079fab798e187
|
SQL
|
zhonghuayichen/crawler
|
/gsxt-jpa/sql/srdb/renfawang.sql
|
UTF-8
| 2,106
| 3.609375
| 4
|
[] |
no_license
|
drop table IF EXISTS t_renfawang_searchresult CASCADE;
drop table IF EXISTS t_renfawang_detail CASCADE;
/*==============================================================*/
/* Table: t_renfawang_searchresult */
/*==============================================================*/
create table t_renfawang_searchresult (
id INT8 not null,
pnum VARCHAR(100) null,
pname VARCHAR(100) null,
zxDate VARCHAR(50) null,
zxNo VARCHAR(100) null,
constraint PK_T_RENFAWANG_SEARCHRESULT primary key (id)
);
comment on column t_renfawang_searchresult.pnum is
'被执行人的详情id';
comment on column t_renfawang_searchresult.pname is
'被执行人姓名/名称';
comment on column t_renfawang_searchresult.zxDate is
'立案时间';
comment on column t_renfawang_searchresult.zxNo is
'案号';
/*==============================================================*/
/* Table: t_renfawang_detail */
/*==============================================================*/
create table t_renfawang_detail (
id INT8 not null,
pname VARCHAR(100) null,
partyCardNum VARCHAR(100) null,
execCourtName VARCHAR(100) null,
caseCreateTime VARCHAR(50) null,
caseCode VARCHAR(100) null,
execMoney VARCHAR(100) null,
constraint PK_T_RENFAWANG_DETAIL primary key (id)
);
comment on column t_renfawang_detail.pname is
'被执行人姓名/名称';
comment on column t_renfawang_detail.partyCardNum is
'身份证号/组织机构代码';
comment on column t_renfawang_detail.execCourtName is
'执行法院';
comment on column t_renfawang_detail.caseCreateTime is
'立案时间';
comment on column t_renfawang_detail.caseCode is
'案号';
comment on column t_renfawang_detail.execMoney is
'执行标的';
| true
|
23ade2612fa8dd693290ba3081d73d47e9eaed74
|
SQL
|
ywf1215/gps-server
|
/conf/bus_geo.sql
|
UTF-8
| 1,138
| 3
| 3
|
[] |
no_license
|
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50618
Source Host : localhost
Source Database : CMS
Target Server Version : 50618
File Encoding : utf-8
Date: 01/29/2016 18:26:17 PM
*/
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `bus_geo`
-- ----------------------------
DROP TABLE IF EXISTS `bus_geo`;
CREATE TABLE `bus_geo` (
`bus` bigint(20) NOT NULL,
`longitude` decimal(8,5) NOT NULL,
`latitude` decimal(8,5) NOT NULL,
`direction` int(11) NOT NULL,
`hourSpeed` int(11) NOT NULL,
`dateTime` datetime NOT NULL,
`timestamp` bigint(20) NOT NULL,
PRIMARY KEY (`bus`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
-- ----------------------------
-- Table structure for `bus_info`
-- ----------------------------
DROP TABLE IF EXISTS `bus_info`;
CREATE TABLE `bus_info` (
`busNum` varchar(32) NOT NULL,
`geoDevID` bigint(20) NOT NULL,
`targetCity` varchar(64) NOT NULL,
PRIMARY KEY (`busNum`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
| true
|
9f2c909ee8725f5e2e0ce8d85d4dfef94683c649
|
SQL
|
silence-do-good/stress-test-Postgres-and-MySQL
|
/dump/high/day15/select2106.sql
|
UTF-8
| 191
| 2.609375
| 3
|
[] |
no_license
|
SELECT timeStamp, temperature
FROM ThermometerObservation
WHERE timestamp>'2017-11-14T21:06:00Z' AND timestamp<'2017-11-15T21:06:00Z' AND SENSOR_ID='b3561273_8e33_400a_bed2_b708cdc91779'
| true
|
d3dbc0c595eb964b6508820e039edc022f1cd535
|
SQL
|
sofie77/Bookish-1
|
/CreateBookishSQLQuery1.sql
|
UTF-8
| 868
| 3.4375
| 3
|
[] |
no_license
|
DROP DATABASE IF EXISTS bookish_dataBase;
CREATE DATABASE bookish_dataBase;
USE bookish_dataBase;
CREATE TABLE Books(
Book_ID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
Book_Name VARCHAR(255) NOT NULL,
Barcode VARCHAR(255) NOT NULL,
ISBN int NOT NULL,
Author VARCHAR(255) NOT NULL
);
CREATE TABLE Users(
UserID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
USerName VARCHAR(255) NOT NULL
);
CREATE TABLE Copies(
CopyID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
UserID INT NOT NULL,
FOREIGN KEY (UserID) REFERENCES Users(UserID),
BookID INT NOT NULL,
FOREIGN KEY (BookID) REFERENCES Books(Book_ID),
);
CREATE TABLE Checkouts(
CheckOutID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
UserID INT NOT NULL,
FOREIGN KEY (UserID) REFERENCES Users(UserID),
CopyID INT NOT NULL,
FOREIGN KEY (CopyID) REFERENCES Copies(CopyID),
Due_Date_Return DATETIME NOT NULL
);
| true
|
8e517676456708d55c2f79acb55e501a7e11a2f5
|
SQL
|
TestBasedRPG/midterm
|
/midterm-q3.sql
|
UTF-8
| 684
| 4.21875
| 4
|
[] |
no_license
|
DROP TABLE if exists authors cascade ;
DROP TABLE if exists books cascade ;
CREATE TABLE if not exists authors (
id serial not null PRIMARY KEY,
author_name text
);
CREATE TABLE if not exists books (
id serial not null PRIMARY KEY,
author_id int4 not null,
title varchar not null,
year int not null default 2021
);
ALTER TABLE books
ADD CONSTRAINT books_author_id_fk1
FOREIGN KEY (author_id)
REFERENCES authors (id)
;
\COPY authors FROM 'midterm-authors-q3.csv' DELIMITER ',' CSV HEADER;
\COPY books FROM 'midterm-books-q3.csv' DELIMITER ',' CSV HEADER;
SELECT * FROM authors
FULL OUTER JOIN books on (authors.id = books.author_id);
| true
|
8cf91bd7781bf5d1c45b3fee9817d79d4c2bf97d
|
SQL
|
yona77/MI3C_GriyaBusanaWanita_Kel.7_FadilaYona
|
/griyabusanawanita_api/griyabusanawanita_api_db.sql
|
UTF-8
| 3,698
| 2.921875
| 3
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: 13 Des 2018 pada 14.31
-- Versi Server: 10.1.21-MariaDB
-- PHP Version: 7.1.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `griyabusanawanita_api_db`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `baju`
--
CREATE TABLE `baju` (
`id_baju` int(10) NOT NULL,
`nama_baju` varchar(50) NOT NULL,
`harga` varchar(70) NOT NULL,
`kategori` varchar(15) NOT NULL,
`photo_url` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `baju`
--
INSERT INTO `baju` (`id_baju`, `nama_baju`, `harga`, `kategori`, `photo_url`) VALUES
(1, 'Blouse Collar', '65000', 'Blouse', 'http://192.168.43.206/android_api/uploads/midorima_x_reader___messages_by_neonsaphir-d84dvd8.jpg'),
(2, 'Kaos Digger', '450000', 'Kaos', 'http://192.168.43.206/android_api/uploads/images_(2).jpg');
-- --------------------------------------------------------
--
-- Struktur dari tabel `pembeli`
--
CREATE TABLE `pembeli` (
`id_pembeli` int(10) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`nama` varchar(50) NOT NULL,
`alamat` varchar(50) NOT NULL,
`telp` int(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `pembeli`
--
INSERT INTO `pembeli` (`id_pembeli`, `username`, `password`, `nama`, `alamat`, `telp`) VALUES
(1, 'Fadila', 'Fadila', 'Fadila Setyabudi', 'Malang', 2147483647),
(2, 'Yona', 'Yona', 'Yona Narulita', 'Lawang', 2147483647);
-- --------------------------------------------------------
--
-- Struktur dari tabel `transaksi`
--
CREATE TABLE `transaksi` (
`id_transaksi` int(10) NOT NULL,
`id_pembeli` int(10) NOT NULL,
`id_baju` int(10) NOT NULL,
`total_harga` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `transaksi`
--
INSERT INTO `transaksi` (`id_transaksi`, `id_pembeli`, `id_baju`, `total_harga`) VALUES
(3, 1, 1, 65000),
(4, 2, 2, 450000);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `baju`
--
ALTER TABLE `baju`
ADD PRIMARY KEY (`id_baju`);
--
-- Indexes for table `pembeli`
--
ALTER TABLE `pembeli`
ADD PRIMARY KEY (`id_pembeli`);
--
-- Indexes for table `transaksi`
--
ALTER TABLE `transaksi`
ADD PRIMARY KEY (`id_transaksi`),
ADD KEY `id_pembeli` (`id_pembeli`),
ADD KEY `id_baju` (`id_baju`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `baju`
--
ALTER TABLE `baju`
MODIFY `id_baju` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `pembeli`
--
ALTER TABLE `pembeli`
MODIFY `id_pembeli` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT for table `transaksi`
--
ALTER TABLE `transaksi`
MODIFY `id_transaksi` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `transaksi`
--
ALTER TABLE `transaksi`
ADD CONSTRAINT `transaksi_ibfk_1` FOREIGN KEY (`id_pembeli`) REFERENCES `pembeli` (`id_pembeli`),
ADD CONSTRAINT `transaksi_ibfk_2` FOREIGN KEY (`id_baju`) REFERENCES `baju` (`id_baju`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
6cb909bb86b647f23b19dcd58102bdc6d67d9f96
|
SQL
|
derrickdjoe/CSE111
|
/derrick-joe-lab3/2.sql
|
UTF-8
| 97
| 2.75
| 3
|
[] |
no_license
|
SELECT s_name, s_acctbal FROM supplier WHERE s_acctbal == (SELECT MIN(s_acctbal) FROM supplier);
| true
|
b93f69034dde563b8d0ec7f63212af197ee62dcf
|
SQL
|
sarithdm/OS-AND-DBMS-LAB-10CS6212
|
/explain.sql
|
UTF-8
| 659
| 2.765625
| 3
|
[] |
no_license
|
CREATE TABLE STUDENT (STUDENTNO INT, STUDENTNAME VARCHAR(20), MATHS INT(10), PHYSICS INT(10), CHEMISTRY INT(10), CPROGRAMMING INT(10), DEPARTMENT VARCHAR(10), ADDRESS VARCHAR(10));
INSERT INTO STUDENT VALUES (100, 'HARI',50,60,45,75,'CSE','KASARAGOD');
INSERT INTO STUDENT VALUES (101, 'DEVI',60,55,78,40,'CSE','KASARAGOD');
INSERT INTO STUDENT VALUES (102, 'SAM',45,77,88,45,'IT','KANNUR');
INSERT INTO STUDENT VALUES (103, 'SREEHARI',90,75,77,60,'IT','CALICUT');
INSERT INTO STUDENT VALUES (104, 'RANI',91,98,89,52,'ECE','KANNUR');
INSERT INTO STUDENT VALUES (105, 'RAJ',88,77,67,48,'CSE','PALAKKAD');
SELECT * FROM STUDENT;
EXPLAIN SELECT * FROM STUDENT;
| true
|
7056c92d5a16cbe59cb38a3375999fbf7d0d3b2f
|
SQL
|
ollej/brewnit
|
/db/structure.sql
|
UTF-8
| 49,959
| 2.984375
| 3
|
[
"MIT"
] |
permissive
|
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
--
-- Name: fermentable_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.fermentable_type AS ENUM (
'Grain',
'Sugar',
'Extract',
'Dry Extract',
'Adjunct'
);
--
-- Name: hop_form; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.hop_form AS ENUM (
'Pellet',
'Plug',
'Leaf'
);
--
-- Name: hop_use; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.hop_use AS ENUM (
'Mash',
'First Wort',
'Boil',
'Aroma',
'Dry Hop'
);
--
-- Name: mash_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.mash_type AS ENUM (
'Infusion',
'Temperature',
'Decoction'
);
--
-- Name: medal; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.medal AS ENUM (
'gold',
'silver',
'bronze'
);
--
-- Name: misc_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.misc_type AS ENUM (
'Spice',
'Fining',
'Water Agent',
'Herb',
'Flavor',
'Other'
);
--
-- Name: misc_use; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.misc_use AS ENUM (
'Mash',
'Boil',
'Primary',
'Secondary',
'Bottling'
);
--
-- Name: yeast_form; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.yeast_form AS ENUM (
'Liquid',
'Dry',
'Slant',
'Culture'
);
--
-- Name: yeast_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.yeast_type AS ENUM (
'Ale',
'Lager',
'Wheat',
'Wine',
'Champagne'
);
--
-- Name: swedish; Type: TEXT SEARCH DICTIONARY; Schema: public; Owner: -
--
CREATE TEXT SEARCH DICTIONARY public.swedish (
TEMPLATE = pg_catalog.ispell,
dictfile = 'sv_se', afffile = 'sv_se', stopwords = 'swedish' );
--
-- Name: swedish_snowball_dict; Type: TEXT SEARCH DICTIONARY; Schema: public; Owner: -
--
CREATE TEXT SEARCH DICTIONARY public.swedish_snowball_dict (
TEMPLATE = pg_catalog.snowball,
language = 'swedish', stopwords = 'swedish' );
--
-- Name: swedish_snowball; Type: TEXT SEARCH CONFIGURATION; Schema: public; Owner: -
--
CREATE TEXT SEARCH CONFIGURATION public.swedish_snowball (
PARSER = pg_catalog."default" );
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR asciiword WITH public.swedish, public.swedish_snowball_dict;
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR word WITH public.swedish, public.swedish_snowball_dict;
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR hword_part WITH public.swedish, public.swedish_snowball_dict;
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR hword_asciipart WITH public.swedish, public.swedish_snowball_dict;
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR asciihword WITH public.swedish, public.swedish_snowball_dict;
ALTER TEXT SEARCH CONFIGURATION public.swedish_snowball
ADD MAPPING FOR hword WITH public.swedish, public.swedish_snowball_dict;
SET default_tablespace = '';
--
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: brew_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.brew_logs (
id bigint NOT NULL,
description text,
brewers character varying,
equipment character varying,
brewed_at date,
bottled_at date,
og numeric,
fg numeric,
preboil_og numeric,
mash_ph numeric,
batch_volume numeric,
boil_volume numeric,
fermenter_volume numeric,
bottled_volume numeric,
user_id bigint NOT NULL,
recipe_id bigint NOT NULL,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: brew_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.brew_logs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: brew_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.brew_logs_id_seq OWNED BY public.brew_logs.id;
--
-- Name: commontator_comments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.commontator_comments (
id integer NOT NULL,
creator_type character varying,
creator_id integer,
editor_type character varying,
editor_id integer,
thread_id integer NOT NULL,
body text NOT NULL,
deleted_at timestamp without time zone,
cached_votes_up integer DEFAULT 0,
cached_votes_down integer DEFAULT 0,
created_at timestamp without time zone,
updated_at timestamp without time zone,
parent_id bigint
);
--
-- Name: commontator_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.commontator_comments_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: commontator_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.commontator_comments_id_seq OWNED BY public.commontator_comments.id;
--
-- Name: commontator_subscriptions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.commontator_subscriptions (
id integer NOT NULL,
subscriber_type character varying NOT NULL,
subscriber_id integer NOT NULL,
thread_id integer NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
--
-- Name: commontator_subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.commontator_subscriptions_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: commontator_subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.commontator_subscriptions_id_seq OWNED BY public.commontator_subscriptions.id;
--
-- Name: commontator_threads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.commontator_threads (
id integer NOT NULL,
commontable_type character varying,
commontable_id integer,
closed_at timestamp without time zone,
closer_type character varying,
closer_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
--
-- Name: commontator_threads_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.commontator_threads_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: commontator_threads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.commontator_threads_id_seq OWNED BY public.commontator_threads.id;
--
-- Name: event_registrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.event_registrations (
id bigint NOT NULL,
message text DEFAULT ''::text NOT NULL,
event_id bigint,
recipe_id bigint,
user_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: event_registrations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.event_registrations_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: event_registrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.event_registrations_id_seq OWNED BY public.event_registrations.id;
--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.events (
id integer NOT NULL,
name character varying DEFAULT ''::character varying,
description character varying DEFAULT ''::character varying,
organizer character varying DEFAULT ''::character varying,
location character varying DEFAULT ''::character varying,
held_at date,
event_type character varying DEFAULT ''::character varying,
url character varying,
user_id integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
media_main_id integer,
last_registration timestamp without time zone,
locked boolean DEFAULT false,
official boolean DEFAULT false,
registration_information text DEFAULT ''::text NOT NULL,
address text DEFAULT ''::text NOT NULL,
coordinates character varying DEFAULT ''::character varying NOT NULL,
contact_email character varying DEFAULT ''::character varying NOT NULL
);
--
-- Name: events_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.events_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.events_id_seq OWNED BY public.events.id;
--
-- Name: events_recipes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.events_recipes (
event_id integer NOT NULL,
recipe_id integer NOT NULL
);
--
-- Name: fermentables; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.fermentables (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
amount numeric DEFAULT 0.0 NOT NULL,
yield numeric DEFAULT 0.0 NOT NULL,
potential numeric DEFAULT 0.0 NOT NULL,
ebc numeric DEFAULT 0.0 NOT NULL,
after_boil boolean DEFAULT false NOT NULL,
fermentable boolean DEFAULT true NOT NULL,
recipe_detail_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
grain_type public.fermentable_type DEFAULT 'Grain'::public.fermentable_type NOT NULL
);
--
-- Name: fermentables_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.fermentables_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: fermentables_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.fermentables_id_seq OWNED BY public.fermentables.id;
--
-- Name: hops; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.hops (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
amount numeric DEFAULT 0.0 NOT NULL,
alpha_acid numeric DEFAULT 0.0 NOT NULL,
use_time numeric DEFAULT 0.0 NOT NULL,
recipe_detail_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
use public.hop_use DEFAULT 'Boil'::public.hop_use NOT NULL,
form public.hop_form DEFAULT 'Leaf'::public.hop_form NOT NULL
);
--
-- Name: hops_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.hops_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: hops_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.hops_id_seq OWNED BY public.hops.id;
--
-- Name: mash_steps; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.mash_steps (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
mash_type public.mash_type NOT NULL,
step_temperature numeric NOT NULL,
step_time numeric NOT NULL,
water_grain_ratio numeric,
infuse_amount numeric,
infuse_temperature numeric,
ramp_time numeric,
end_temperature numeric,
decoction_amount numeric,
description text DEFAULT ''::text NOT NULL,
recipe_detail_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: mash_steps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.mash_steps_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: mash_steps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.mash_steps_id_seq OWNED BY public.mash_steps.id;
--
-- Name: media; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.media (
id integer NOT NULL,
file character varying,
caption character varying,
sorting integer,
parent_type character varying,
parent_id integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
file_file_name character varying,
file_content_type character varying,
file_file_size bigint,
file_updated_at timestamp without time zone
);
--
-- Name: media_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.media_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: media_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.media_id_seq OWNED BY public.media.id;
--
-- Name: miscs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.miscs (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
weight boolean DEFAULT true NOT NULL,
amount numeric DEFAULT 0.0 NOT NULL,
use_time numeric DEFAULT 0.0 NOT NULL,
recipe_detail_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
use public.misc_use DEFAULT 'Boil'::public.misc_use NOT NULL,
misc_type public.misc_type DEFAULT 'Other'::public.misc_type NOT NULL
);
--
-- Name: miscs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.miscs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: miscs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.miscs_id_seq OWNED BY public.miscs.id;
--
-- Name: placements; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.placements (
id integer NOT NULL,
medal public.medal,
category character varying DEFAULT ''::character varying,
locked boolean DEFAULT false,
recipe_id integer,
event_id integer,
user_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
--
-- Name: placements_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.placements_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: placements_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.placements_id_seq OWNED BY public.placements.id;
--
-- Name: recipe_details; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.recipe_details (
id bigint NOT NULL,
batch_size numeric,
boil_size numeric,
boil_time numeric,
grain_temp numeric,
sparge_temp numeric,
efficiency numeric,
recipe_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
og numeric DEFAULT 0.0 NOT NULL,
fg numeric DEFAULT 0.0 NOT NULL,
brewed_at date,
carbonation numeric DEFAULT 0.0 NOT NULL,
style_id bigint
);
--
-- Name: recipe_details_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.recipe_details_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: recipe_details_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.recipe_details_id_seq OWNED BY public.recipe_details.id;
--
-- Name: recipes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.recipes (
id integer NOT NULL,
name character varying DEFAULT ''::character varying,
description text DEFAULT ''::text,
beerxml text,
public boolean,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
user_id integer,
abv numeric,
ibu numeric,
og numeric,
fg numeric,
style_code character varying,
style_guide character varying,
style_name character varying DEFAULT ''::character varying,
batch_size numeric,
color numeric,
brewer character varying DEFAULT ''::character varying,
downloads integer DEFAULT 0 NOT NULL,
media_main_id integer,
cached_votes_up integer DEFAULT 0,
equipment character varying DEFAULT ''::character varying,
complete boolean DEFAULT false NOT NULL
);
--
-- Name: recipes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.recipes_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: recipes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.recipes_id_seq OWNED BY public.recipes.id;
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);
--
-- Name: styles; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.styles (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
description text DEFAULT ''::text NOT NULL,
category character varying DEFAULT ''::character varying NOT NULL,
number integer NOT NULL,
letter character varying NOT NULL,
aroma text DEFAULT ''::text NOT NULL,
appearance text DEFAULT ''::text NOT NULL,
flavor text DEFAULT ''::text NOT NULL,
texture text DEFAULT ''::text NOT NULL,
examples text DEFAULT ''::text NOT NULL,
summary text DEFAULT ''::text NOT NULL,
og_min numeric DEFAULT 0.0 NOT NULL,
og_max numeric DEFAULT 0.0 NOT NULL,
fg_min numeric DEFAULT 0.0 NOT NULL,
fg_max numeric DEFAULT 0.0 NOT NULL,
ebc_min numeric DEFAULT 0.0 NOT NULL,
ebc_max numeric DEFAULT 0.0 NOT NULL,
ibu_min numeric DEFAULT 0.0 NOT NULL,
ibu_max numeric DEFAULT 0.0 NOT NULL,
abv_min numeric DEFAULT 0.0 NOT NULL,
abv_max numeric DEFAULT 0.0 NOT NULL,
style_guide character varying DEFAULT ''::character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: styles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.styles_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: styles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.styles_id_seq OWNED BY public.styles.id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id integer NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
email character varying DEFAULT ''::character varying NOT NULL,
encrypted_password character varying DEFAULT ''::character varying NOT NULL,
reset_password_token character varying,
reset_password_sent_at timestamp without time zone,
remember_created_at timestamp without time zone,
sign_in_count integer DEFAULT 0 NOT NULL,
current_sign_in_at timestamp without time zone,
last_sign_in_at timestamp without time zone,
current_sign_in_ip inet,
last_sign_in_ip inet,
confirmation_token character varying,
confirmed_at timestamp without time zone,
confirmation_sent_at timestamp without time zone,
unconfirmed_email character varying,
failed_attempts integer DEFAULT 0 NOT NULL,
unlock_token character varying,
locked_at timestamp without time zone,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
admin boolean,
presentation text DEFAULT ''::text,
location character varying,
brewery character varying DEFAULT ''::character varying,
twitter character varying DEFAULT ''::character varying,
url character varying,
equipment character varying DEFAULT ''::character varying,
media_avatar_id integer,
media_brewery_id integer,
registration_data jsonb,
recipes_count integer DEFAULT 0,
instagram text,
receive_email boolean DEFAULT false,
uid character varying,
provider character varying,
native_notifications boolean DEFAULT true,
pushover_user_key character varying,
geocode jsonb
);
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- Name: votes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.votes (
id integer NOT NULL,
votable_type character varying,
votable_id integer,
voter_type character varying,
voter_id integer,
vote_flag boolean,
vote_scope character varying,
vote_weight integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
--
-- Name: votes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.votes_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: votes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.votes_id_seq OWNED BY public.votes.id;
--
-- Name: yeasts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.yeasts (
id bigint NOT NULL,
name character varying DEFAULT ''::character varying NOT NULL,
weight boolean DEFAULT true NOT NULL,
amount numeric DEFAULT 0.0 NOT NULL,
recipe_detail_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
form public.yeast_form DEFAULT 'Dry'::public.yeast_form NOT NULL,
yeast_type public.yeast_type DEFAULT 'Ale'::public.yeast_type NOT NULL,
product_id text
);
--
-- Name: yeasts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.yeasts_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: yeasts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.yeasts_id_seq OWNED BY public.yeasts.id;
--
-- Name: brew_logs id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.brew_logs ALTER COLUMN id SET DEFAULT nextval('public.brew_logs_id_seq'::regclass);
--
-- Name: commontator_comments id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_comments ALTER COLUMN id SET DEFAULT nextval('public.commontator_comments_id_seq'::regclass);
--
-- Name: commontator_subscriptions id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_subscriptions ALTER COLUMN id SET DEFAULT nextval('public.commontator_subscriptions_id_seq'::regclass);
--
-- Name: commontator_threads id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_threads ALTER COLUMN id SET DEFAULT nextval('public.commontator_threads_id_seq'::regclass);
--
-- Name: event_registrations id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.event_registrations ALTER COLUMN id SET DEFAULT nextval('public.event_registrations_id_seq'::regclass);
--
-- Name: events id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events ALTER COLUMN id SET DEFAULT nextval('public.events_id_seq'::regclass);
--
-- Name: fermentables id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.fermentables ALTER COLUMN id SET DEFAULT nextval('public.fermentables_id_seq'::regclass);
--
-- Name: hops id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.hops ALTER COLUMN id SET DEFAULT nextval('public.hops_id_seq'::regclass);
--
-- Name: mash_steps id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.mash_steps ALTER COLUMN id SET DEFAULT nextval('public.mash_steps_id_seq'::regclass);
--
-- Name: media id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.media ALTER COLUMN id SET DEFAULT nextval('public.media_id_seq'::regclass);
--
-- Name: miscs id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.miscs ALTER COLUMN id SET DEFAULT nextval('public.miscs_id_seq'::regclass);
--
-- Name: placements id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.placements ALTER COLUMN id SET DEFAULT nextval('public.placements_id_seq'::regclass);
--
-- Name: recipe_details id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipe_details ALTER COLUMN id SET DEFAULT nextval('public.recipe_details_id_seq'::regclass);
--
-- Name: recipes id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipes ALTER COLUMN id SET DEFAULT nextval('public.recipes_id_seq'::regclass);
--
-- Name: styles id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.styles ALTER COLUMN id SET DEFAULT nextval('public.styles_id_seq'::regclass);
--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- Name: votes id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.votes ALTER COLUMN id SET DEFAULT nextval('public.votes_id_seq'::regclass);
--
-- Name: yeasts id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.yeasts ALTER COLUMN id SET DEFAULT nextval('public.yeasts_id_seq'::regclass);
--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
--
-- Name: brew_logs brew_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.brew_logs
ADD CONSTRAINT brew_logs_pkey PRIMARY KEY (id);
--
-- Name: commontator_comments commontator_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_comments
ADD CONSTRAINT commontator_comments_pkey PRIMARY KEY (id);
--
-- Name: commontator_subscriptions commontator_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_subscriptions
ADD CONSTRAINT commontator_subscriptions_pkey PRIMARY KEY (id);
--
-- Name: commontator_threads commontator_threads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_threads
ADD CONSTRAINT commontator_threads_pkey PRIMARY KEY (id);
--
-- Name: event_registrations event_registrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.event_registrations
ADD CONSTRAINT event_registrations_pkey PRIMARY KEY (id);
--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
--
-- Name: fermentables fermentables_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.fermentables
ADD CONSTRAINT fermentables_pkey PRIMARY KEY (id);
--
-- Name: hops hops_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.hops
ADD CONSTRAINT hops_pkey PRIMARY KEY (id);
--
-- Name: mash_steps mash_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.mash_steps
ADD CONSTRAINT mash_steps_pkey PRIMARY KEY (id);
--
-- Name: media media_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.media
ADD CONSTRAINT media_pkey PRIMARY KEY (id);
--
-- Name: miscs miscs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.miscs
ADD CONSTRAINT miscs_pkey PRIMARY KEY (id);
--
-- Name: placements placements_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.placements
ADD CONSTRAINT placements_pkey PRIMARY KEY (id);
--
-- Name: recipe_details recipe_details_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipe_details
ADD CONSTRAINT recipe_details_pkey PRIMARY KEY (id);
--
-- Name: recipes recipes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipes
ADD CONSTRAINT recipes_pkey PRIMARY KEY (id);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: styles styles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.styles
ADD CONSTRAINT styles_pkey PRIMARY KEY (id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.votes
ADD CONSTRAINT votes_pkey PRIMARY KEY (id);
--
-- Name: yeasts yeasts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.yeasts
ADD CONSTRAINT yeasts_pkey PRIMARY KEY (id);
--
-- Name: events_name_trigram_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_name_trigram_idx ON public.events USING gin (name public.gin_trgm_ops);
--
-- Name: fulltext_index_events_on_name; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_events_on_name ON public.events USING gin (to_tsvector('public.swedish_snowball'::regconfig, (COALESCE(name, ''::character varying))::text));
--
-- Name: fulltext_index_events_on_primary; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_events_on_primary ON public.events USING gin (to_tsvector('public.swedish_snowball'::regconfig, (((((((((COALESCE(name, ''::character varying))::text || ' '::text) || (COALESCE(organizer, ''::character varying))::text) || ' '::text) || (COALESCE(location, ''::character varying))::text) || ' '::text) || (COALESCE(event_type, ''::character varying))::text) || ' '::text) || (COALESCE(description, ''::character varying))::text)));
--
-- Name: fulltext_index_recipes_on_equipment; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_recipes_on_equipment ON public.recipes USING gin (to_tsvector('public.swedish_snowball'::regconfig, (COALESCE(equipment, ''::character varying))::text));
--
-- Name: fulltext_index_recipes_on_primary; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_recipes_on_primary ON public.recipes USING gin (to_tsvector('public.swedish_snowball'::regconfig, (((((((((COALESCE(name, ''::character varying))::text || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || (COALESCE(style_name, ''::character varying))::text) || ' '::text) || (COALESCE(equipment, ''::character varying))::text) || ' '::text) || (COALESCE(brewer, ''::character varying))::text)));
--
-- Name: fulltext_index_recipes_on_style_name; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_recipes_on_style_name ON public.recipes USING gin (to_tsvector('simple'::regconfig, (style_name)::text));
--
-- Name: fulltext_index_users_on_brewery; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_users_on_brewery ON public.users USING gin (to_tsvector('public.swedish_snowball'::regconfig, (COALESCE(brewery, ''::character varying))::text));
--
-- Name: fulltext_index_users_on_equipment; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_users_on_equipment ON public.users USING gin (to_tsvector('public.swedish_snowball'::regconfig, (COALESCE(equipment, ''::character varying))::text));
--
-- Name: fulltext_index_users_on_name; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_users_on_name ON public.users USING gin (to_tsvector('simple'::regconfig, (name)::text));
--
-- Name: fulltext_index_users_on_primary; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fulltext_index_users_on_primary ON public.users USING gin (to_tsvector('public.swedish_snowball'::regconfig, (((((((((COALESCE(name, ''::character varying))::text || ' '::text) || COALESCE(presentation, ''::text)) || ' '::text) || (COALESCE(equipment, ''::character varying))::text) || ' '::text) || (COALESCE(brewery, ''::character varying))::text) || ' '::text) || (COALESCE(twitter, ''::character varying))::text)));
--
-- Name: index_brew_logs_on_recipe_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_brew_logs_on_recipe_id ON public.brew_logs USING btree (recipe_id);
--
-- Name: index_brew_logs_on_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_brew_logs_on_user_id ON public.brew_logs USING btree (user_id);
--
-- Name: index_commontator_comments_on_c_id_and_c_type_and_t_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_comments_on_c_id_and_c_type_and_t_id ON public.commontator_comments USING btree (creator_id, creator_type, thread_id);
--
-- Name: index_commontator_comments_on_cached_votes_down; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_comments_on_cached_votes_down ON public.commontator_comments USING btree (cached_votes_down);
--
-- Name: index_commontator_comments_on_cached_votes_up; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_comments_on_cached_votes_up ON public.commontator_comments USING btree (cached_votes_up);
--
-- Name: index_commontator_comments_on_parent_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_comments_on_parent_id ON public.commontator_comments USING btree (parent_id);
--
-- Name: index_commontator_comments_on_thread_id_and_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_comments_on_thread_id_and_created_at ON public.commontator_comments USING btree (thread_id, created_at);
--
-- Name: index_commontator_subscriptions_on_s_id_and_s_type_and_t_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_commontator_subscriptions_on_s_id_and_s_type_and_t_id ON public.commontator_subscriptions USING btree (subscriber_id, subscriber_type, thread_id);
--
-- Name: index_commontator_subscriptions_on_thread_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_commontator_subscriptions_on_thread_id ON public.commontator_subscriptions USING btree (thread_id);
--
-- Name: index_commontator_threads_on_c_id_and_c_type; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_commontator_threads_on_c_id_and_c_type ON public.commontator_threads USING btree (commontable_id, commontable_type);
--
-- Name: index_event_registrations_on_event_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_event_registrations_on_event_id ON public.event_registrations USING btree (event_id);
--
-- Name: index_event_registrations_on_recipe_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_event_registrations_on_recipe_id ON public.event_registrations USING btree (recipe_id);
--
-- Name: index_event_registrations_on_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_event_registrations_on_user_id ON public.event_registrations USING btree (user_id);
--
-- Name: index_events_on_media_main_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_events_on_media_main_id ON public.events USING btree (media_main_id);
--
-- Name: index_events_on_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_events_on_user_id ON public.events USING btree (user_id);
--
-- Name: index_events_recipes_on_event_id_and_recipe_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_events_recipes_on_event_id_and_recipe_id ON public.events_recipes USING btree (event_id, recipe_id);
--
-- Name: index_events_recipes_on_recipe_id_and_event_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_events_recipes_on_recipe_id_and_event_id ON public.events_recipes USING btree (recipe_id, event_id);
--
-- Name: index_fermentables_on_recipe_detail_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_fermentables_on_recipe_detail_id ON public.fermentables USING btree (recipe_detail_id);
--
-- Name: index_hops_on_recipe_detail_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_hops_on_recipe_detail_id ON public.hops USING btree (recipe_detail_id);
--
-- Name: index_mash_steps_on_recipe_detail_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_mash_steps_on_recipe_detail_id ON public.mash_steps USING btree (recipe_detail_id);
--
-- Name: index_media_on_parent; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_media_on_parent ON public.media USING btree (parent_type, parent_id);
--
-- Name: index_miscs_on_recipe_detail_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_miscs_on_recipe_detail_id ON public.miscs USING btree (recipe_detail_id);
--
-- Name: index_placements_on_event_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_placements_on_event_id ON public.placements USING btree (event_id);
--
-- Name: index_placements_on_medal; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_placements_on_medal ON public.placements USING btree (medal);
--
-- Name: index_placements_on_recipe_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_placements_on_recipe_id ON public.placements USING btree (recipe_id);
--
-- Name: index_placements_on_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_placements_on_user_id ON public.placements USING btree (user_id);
--
-- Name: index_recipe_details_on_recipe_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipe_details_on_recipe_id ON public.recipe_details USING btree (recipe_id);
--
-- Name: index_recipe_details_on_style_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipe_details_on_style_id ON public.recipe_details USING btree (style_id);
--
-- Name: index_recipes_on_abv; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_abv ON public.recipes USING btree (abv);
--
-- Name: index_recipes_on_batch_size; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_batch_size ON public.recipes USING btree (batch_size);
--
-- Name: index_recipes_on_brewer; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_brewer ON public.recipes USING btree (brewer);
--
-- Name: index_recipes_on_cached_votes_up; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_cached_votes_up ON public.recipes USING btree (cached_votes_up);
--
-- Name: index_recipes_on_color; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_color ON public.recipes USING btree (color);
--
-- Name: index_recipes_on_complete; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_complete ON public.recipes USING btree (complete);
--
-- Name: index_recipes_on_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_created_at ON public.recipes USING btree (created_at);
--
-- Name: index_recipes_on_fg; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_fg ON public.recipes USING btree (fg);
--
-- Name: index_recipes_on_ibu; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_ibu ON public.recipes USING btree (ibu);
--
-- Name: index_recipes_on_media_main_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_media_main_id ON public.recipes USING btree (media_main_id);
--
-- Name: index_recipes_on_og; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_og ON public.recipes USING btree (og);
--
-- Name: index_recipes_on_public; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_public ON public.recipes USING btree (public);
--
-- Name: index_recipes_on_style_code; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_style_code ON public.recipes USING btree (style_code);
--
-- Name: index_recipes_on_style_guide; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_style_guide ON public.recipes USING btree (style_guide);
--
-- Name: index_recipes_on_style_name; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_style_name ON public.recipes USING btree (style_name);
--
-- Name: index_recipes_on_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_recipes_on_user_id ON public.recipes USING btree (user_id);
--
-- Name: index_styles_on_style_guide; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_styles_on_style_guide ON public.styles USING btree (style_guide);
--
-- Name: index_users_on_confirmation_token; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_users_on_confirmation_token ON public.users USING btree (confirmation_token);
--
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email);
--
-- Name: index_users_on_media_avatar_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_users_on_media_avatar_id ON public.users USING btree (media_avatar_id);
--
-- Name: index_users_on_media_brewery_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_users_on_media_brewery_id ON public.users USING btree (media_brewery_id);
--
-- Name: index_users_on_name; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_users_on_name ON public.users USING btree (name);
--
-- Name: index_users_on_reset_password_token; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_users_on_reset_password_token ON public.users USING btree (reset_password_token);
--
-- Name: index_users_on_unlock_token; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_users_on_unlock_token ON public.users USING btree (unlock_token);
--
-- Name: index_votes_on_votable_id_and_votable_type_and_vote_scope; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_votes_on_votable_id_and_votable_type_and_vote_scope ON public.votes USING btree (votable_id, votable_type, vote_scope);
--
-- Name: index_votes_on_voter_id_and_voter_type_and_vote_scope; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_votes_on_voter_id_and_voter_type_and_vote_scope ON public.votes USING btree (voter_id, voter_type, vote_scope);
--
-- Name: index_yeasts_on_recipe_detail_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_yeasts_on_recipe_detail_id ON public.yeasts USING btree (recipe_detail_id);
--
-- Name: recipe_names_trigram_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX recipe_names_trigram_idx ON public.recipes USING gin (name public.gin_trgm_ops);
--
-- Name: user_name_trigram_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX user_name_trigram_idx ON public.users USING gin (name public.gin_trgm_ops);
--
-- Name: mash_steps fk_rails_0f11dbd377; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.mash_steps
ADD CONSTRAINT fk_rails_0f11dbd377 FOREIGN KEY (recipe_detail_id) REFERENCES public.recipe_details(id);
--
-- Name: recipes fk_rails_0fd2ed4eeb; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipes
ADD CONSTRAINT fk_rails_0fd2ed4eeb FOREIGN KEY (media_main_id) REFERENCES public.media(id);
--
-- Name: event_registrations fk_rails_23148f43c2; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.event_registrations
ADD CONSTRAINT fk_rails_23148f43c2 FOREIGN KEY (event_id) REFERENCES public.events(id);
--
-- Name: placements fk_rails_344f224d46; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.placements
ADD CONSTRAINT fk_rails_344f224d46 FOREIGN KEY (recipe_id) REFERENCES public.recipes(id);
--
-- Name: recipe_details fk_rails_426b7d6920; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipe_details
ADD CONSTRAINT fk_rails_426b7d6920 FOREIGN KEY (style_id) REFERENCES public.styles(id);
--
-- Name: miscs fk_rails_4aca03e5cb; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.miscs
ADD CONSTRAINT fk_rails_4aca03e5cb FOREIGN KEY (recipe_detail_id) REFERENCES public.recipe_details(id);
--
-- Name: commontator_comments fk_rails_558e599d00; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.commontator_comments
ADD CONSTRAINT fk_rails_558e599d00 FOREIGN KEY (parent_id) REFERENCES public.commontator_comments(id) ON UPDATE RESTRICT ON DELETE CASCADE;
--
-- Name: hops fk_rails_58ff15d669; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.hops
ADD CONSTRAINT fk_rails_58ff15d669 FOREIGN KEY (recipe_detail_id) REFERENCES public.recipe_details(id);
--
-- Name: users fk_rails_793a220a68; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT fk_rails_793a220a68 FOREIGN KEY (media_avatar_id) REFERENCES public.media(id);
--
-- Name: placements fk_rails_7f5b80573c; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.placements
ADD CONSTRAINT fk_rails_7f5b80573c FOREIGN KEY (event_id) REFERENCES public.events(id);
--
-- Name: event_registrations fk_rails_8a0b1c0506; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.event_registrations
ADD CONSTRAINT fk_rails_8a0b1c0506 FOREIGN KEY (recipe_id) REFERENCES public.recipes(id);
--
-- Name: recipe_details fk_rails_9509a5b996; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.recipe_details
ADD CONSTRAINT fk_rails_9509a5b996 FOREIGN KEY (recipe_id) REFERENCES public.recipes(id);
--
-- Name: users fk_rails_9c9dd5b0b7; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT fk_rails_9c9dd5b0b7 FOREIGN KEY (media_brewery_id) REFERENCES public.media(id);
--
-- Name: event_registrations fk_rails_9d37217e35; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.event_registrations
ADD CONSTRAINT fk_rails_9d37217e35 FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- Name: brew_logs fk_rails_9ff6a4b31a; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.brew_logs
ADD CONSTRAINT fk_rails_9ff6a4b31a FOREIGN KEY (recipe_id) REFERENCES public.recipes(id);
--
-- Name: brew_logs fk_rails_d284aafe2c; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.brew_logs
ADD CONSTRAINT fk_rails_d284aafe2c FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- Name: yeasts fk_rails_e5e114c272; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.yeasts
ADD CONSTRAINT fk_rails_e5e114c272 FOREIGN KEY (recipe_detail_id) REFERENCES public.recipe_details(id);
--
-- Name: events fk_rails_eddd50df5b; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT fk_rails_eddd50df5b FOREIGN KEY (media_main_id) REFERENCES public.media(id);
--
-- Name: fermentables fk_rails_fa5fd15b19; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.fermentables
ADD CONSTRAINT fk_rails_fa5fd15b19 FOREIGN KEY (recipe_detail_id) REFERENCES public.recipe_details(id);
--
-- Name: placements fk_rails_fe81c39da1; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.placements
ADD CONSTRAINT fk_rails_fe81c39da1 FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- PostgreSQL database dump complete
--
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20151214195013'),
('20151214200025'),
('20151214210544'),
('20151214210606'),
('20151215200333'),
('20151223113228'),
('20151223125714'),
('20160102165716'),
('20160102173544'),
('20160102210028'),
('20160105190205'),
('20160105234837'),
('20160112215316'),
('20160119204655'),
('20160119214911'),
('20160124162437'),
('20160124174400'),
('20160209201838'),
('20160307193952'),
('20161213184727'),
('20170127111423'),
('20170130190351'),
('20171025204911'),
('20171027223202'),
('20171028120552'),
('20171028145021'),
('20171029201125'),
('20171102202524'),
('20171107191308'),
('20171113205317'),
('20171114204510'),
('20171115220620'),
('20171115220627'),
('20171115221112'),
('20171115221353'),
('20171115221645'),
('20171119161104'),
('20171119165458'),
('20171119182201'),
('20171119190427'),
('20171121184814'),
('20171122201201'),
('20171126121130'),
('20171126161659'),
('20171202132847'),
('20171203174307'),
('20171212222842'),
('20171228154504'),
('20180205191232'),
('20180205201540'),
('20180205203125'),
('20180501134640'),
('20180501150416'),
('20180501151104'),
('20190324004643'),
('20200613142912'),
('20200613154041'),
('20200613182041'),
('20200613184054'),
('20200616170418'),
('20200620114227'),
('20200620124947'),
('20210308201612'),
('20221117125254'),
('20230504114826'),
('20230504114827'),
('20230504114828');
| true
|
a654fdbdff44997756843737ad1ebe23f0211271
|
SQL
|
Yrp/explorer
|
/model/src/main/resources/trxplorer/db/migration/common/schema/V0044__AccountVote_add_table.sql
|
UTF-8
| 247
| 2.546875
| 3
|
[] |
no_license
|
CREATE TABLE `account_vote` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`vote_address` VARCHAR(45) NOT NULL,
`vote_account_id` VARCHAR(45) NULL,
`vote_count` BIGINT UNSIGNED NOT NULL,
`account_id` BIGINT NULL,
PRIMARY KEY (`id`));
| true
|
8bd3ebf7e6a6d1ffbd958d5f6a357759968ce4f2
|
SQL
|
Cassiep1986/MySQL-Homework-Employee-Tracker
|
/seed.sql
|
UTF-8
| 803
| 3.4375
| 3
|
[
"MIT"
] |
permissive
|
use tracker_db;
INSERT INTO
department (name)
VALUES
('Pharmacy'),
('HR'),
('Corporate');
INSERT INTO
role (title, salary, department_id)
VALUES
('Pharmacy Tech', 40000, 1),
('Pharmacy Lead', 45000, 1),
('Pharmacist', 120000, 1),
('Human Resources Manager', 80000, 2),
('CEO', 500000, 3),
('Administrative assistant', 60000, 3),
('Sales Representative', 100000, 3);
INSERT INTO
employee (first_name, last_name, role_id)
VALUES
('Jessie', 'Pinkman', 1),
('Earl', 'Hickey', 2),
('Walter', 'White', 3),
('Rita', 'Castillo', 4),
('Harold', 'Lee', 5),
('Kumar', 'Patel', 6),
('Rick', 'Sanchez', 7),
('Morty', 'Smith', 1);
SELECT
*
FROM
department;
SELECT
*
FROM
role;
SELECT
*
FROM
employee;
| true
|
da8af8b4b84361c62830aa9feadf3769db5c2a9f
|
SQL
|
radtek/Database-3
|
/oracle/admin/scripts/OWB_refrescos.sql
|
UTF-8
| 2,671
| 3.703125
| 4
|
[] |
no_license
|
set linesize 300
set pagesize 100
col NOMBRE_WORKBOOK format a100
select c.scd_surrgt_pk, c.scd_ins_surrgt_fk, COUNT(a.cch_url) cant_work,
MIN(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5,instr(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5),']') -1)) nombre_workbook,
max(scd_last_updated) max_scd_last_update,
max(scd_next_update) max_scd_next_update,
max(a.cch_last_updated) max_cch_last_updated
FROM discoverer5.ptm5_cache a, DISCOVERER5.PTM5_SCHEDULE c
WHERE a.cch_ins_surrgt_fk = c.scd_ins_surrgt_fk
GROUP BY c.scd_surrgt_pk, c.scd_ins_surrgt_fk
-- ORDER BY max_scd_last_update,max_scd_next_update,
-- MIN(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5,instr(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5),']') -1))
order by max_cch_last_updated
/
SELECT scd.scd_last_updated, scd.scd_next_update, ins.ins_id, plt.plt_id_uk, ptn.ptn_id_uk
FROM discoverer5.ptm5_schedule scd, discoverer5.ptm5_instance ins, discoverer5.ptm5_portlet plt, discoverer5.ptm5_partition ptn
WHERE scd.scd_next_update = (SELECT MIN(scd_next_update) FROM discoverer5.ptm5_schedule)
AND ins.ins_surrgt_pk = scd.scd_ins_surrgt_fk
AND plt.plt_surrgt_pk = ins.ins_plt_surrgt_fk
AND ptn.ptn_surrgt_pk = ins.ins_ptn_surrgt_fk
/
select c.scd_surrgt_pk, c.scd_ins_surrgt_fk, COUNT(a.cch_url) cant_work,
MIN(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5,instr(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5),']') -1)) nombre_workbook,
max(scd_last_updated) max_scd_last_update,
max(scd_next_update) max_scd_next_update,
max(a.cch_last_updated) max_cch_last_updated
FROM discoverer5.ptm5_cache a, DISCOVERER5.PTM5_SCHEDULE c
WHERE a.cch_ins_surrgt_fk = c.scd_ins_surrgt_fk
and a.cch_ins_surrgt_fk=
SELECT ins.ins_ptn_surrgt_fk
FROM discoverer5.ptm5_schedule scd, discoverer5.ptm5_instance ins, discoverer5.ptm5_portlet plt, discoverer5.ptm5_partition ptn
WHERE scd.scd_next_update = (SELECT MIN(scd_next_update) FROM discoverer5.ptm5_schedule)
AND ins.ins_surrgt_pk = scd.scd_ins_surrgt_fk
AND plt.plt_surrgt_pk = ins.ins_plt_surrgt_fk
AND ptn.ptn_surrgt_pk = ins.ins_ptn_surrgt_fk)
GROUP BY c.scd_surrgt_pk, c.scd_ins_surrgt_fk
ORDER BY max_scd_last_update,max_scd_next_update,
MIN(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5,instr(substr(a.CCH_URL,instr(a.CCH_URL,'wb_k=')+5),']') -1))
/
SELECT min(a.cch_last_updated),max(a.cch_last_updated),
min(a.cch_next_update),max(a.cch_next_update),min(a.cch_type),max(a.cch_type),
min(a.cch_ins_surrgt_fk),max(a.cch_ins_surrgt_fk),
min(a.cch_immed_refresh),max(a.cch_immed_refresh),
min(a.cch_sched_refresh), max(a.cch_sched_refresh)
FROM discoverer5.ptm5_cache a
ORDER BY a.cch_last_updated ASC
/
| true
|
222e8599b82a2023528b04935cda4f92656799a2
|
SQL
|
pedjasim/OraclePosttest_NovcanoPoslovanje
|
/PackageBodies/F9_PACKAGE.sql
|
UTF-8
| 3,343
| 3.21875
| 3
|
[] |
no_license
|
CREATE OR REPLACE PACKAGE BODY F9_PACKAGE is
PROCEDURE UGOVOR_F9(P_DELOVODNI_BROJ UGOVOR.DELOVODNI_BROJ%TYPE,
P_DATUM IN VARCHAR2,
P_CURSOR OUT T_CURSOR) IS
BEGIN
open P_CURSOR for
select u.id_ugovor,
trim(u.delovodni_broj) || ' (' || pp.naziv_f9 || ')' delovodni_broj
from poslovno_okruzenje.ugovor u,
poslovno_okruzenje.ugovor_poslovnog_partnera upp,
poslovno_okruzenje.poslovni_partner pp
where u.delovodni_broj like P_DELOVODNI_BROJ || '%'
and to_date(P_DATUM, 'dd.mm.yyyy') between trunc(u.datum_primene) and
nvl(trunc(u.datum_prestanka_vazenja),
to_date('31.12.2222', 'dd.mm.yyyy'))
and upp.id_ugovor = u.id_ugovor
and upp.id_poslovni_partner = pp.id_poslovni_partner
order by trim(u.delovodni_broj);
END UGOVOR_F9;
PROCEDURE KOMITENT_F9(P_ID_UGOVOR IN UGOVOR_POSLOVNOG_PARTNERA.ID_UGOVOR%TYPE,
P_NAZIV_F9 IN POSLOVNI_PARTNER.NAZIV_F9%TYPE,
P_CURSOR OUT T_CURSOR) IS
BEGIN
OPEN P_CURSOR FOR
select pp.id_poslovni_partner,
pp.naziv_f9 sifra_naziv_komitenta
from poslovno_okruzenje.ugovor_poslovnog_partnera upp,
poslovno_okruzenje.poslovni_partner pp
where upp.id_ugovor = P_ID_UGOVOR
and pp.naziv_f9 like '%' || P_NAZIV_F9 || '%'
and pp.status = 'A'
and pp.id_poslovni_partner = upp.id_poslovni_partner;
END KOMITENT_F9;
PROCEDURE UGOVORENA_USLUGA_F9(P_ID_UGOVOR IN UGOVORENA_USLUGA.ID_UGOVOR%TYPE,
P_NAZIV IN USLUGE.NAZIV%TYPE,
P_CURSOR OUT T_CURSOR) IS
BEGIN
OPEN P_CURSOR FOR
select uu.id_ugovorena_usluga, u.naziv
from poslovno_okruzenje.ugovorena_usluga uu,
poslovno_okruzenje.usluge u
where uu.id_ugovor = P_ID_UGOVOR
and u.id_usluge = uu.id_usluga
and u.naziv like '%' || P_NAZIV || '%'
order by u.naziv;
END UGOVORENA_USLUGA_F9;
PROCEDURE KOMITENT_PRETRAGA_F9(P_NAZIV_F9 IN POSLOVNI_PARTNER.NAZIV_F9%TYPE,
P_CURSOR OUT T_CURSOR) IS
BEGIN
OPEN P_CURSOR FOR
select pp.id_poslovni_partner,
pp.naziv_f9 sifra_naziv_komitenta
from poslovno_okruzenje.poslovni_partner pp
where pp.naziv_f9 like P_NAZIV_F9
and pp.status = 'A';
END KOMITENT_PRETRAGA_F9;
PROCEDURE PRIJAVA_PRETRAGA_F9(P_CURSOR OUT T_CURSOR) IS
BEGIN
OPEN P_CURSOR FOR
select p.ID_PRIJAVA,p.NAZIV_PRIJAVE,p.VRSTA_PRIJAVE
from novcano_poslovanje.prijava p
where p.VRSTA_PRIJAVE like 'K';
END PRIJAVA_PRETRAGA_F9;
PROCEDURE KOMITENT_NAZIV_F9(
P_ID_CPM_DAN IN TRANSAKCIJA_KOMITENT.ID_CPM_DAN%TYPE,
P_CURSOR OUT T_CURSOR) IS
BEGIN
OPEN P_CURSOR FOR
select distinct pp.naziv_f9 sifra_naziv_komitenta
from poslovno_okruzenje.poslovni_partner pp,TRANSAKCIJA_KOMITENT tk
where tk.SIFRA_KOMITENTA = pp.ID_POSLOVNI_PARTNER
AND TK.ID_CPM_DAN=P_ID_CPM_DAN;
END KOMITENT_NAZIV_F9;
END F9_PACKAGE;
/
SHOW ERRORS;
| true
|
74b97dda0a2f70e2f1b9ad56a5475f35e3cd6f03
|
SQL
|
Mkkiyoi/Burger
|
/db/schema.sql
|
UTF-8
| 251
| 2.578125
| 3
|
[] |
no_license
|
-- Schema for BurgerDB
DROP DATABASE IF EXISTS BurgerDB;
CREATE DATABASE BurgerDB;
USE BurgerDB;
CREATE TABLE Burgers (
BurgersID INT PRIMARY KEY AUTO_INCREMENT,
BurgerName VARCHAR(30) NOT NULL,
DEVOURED BOOLEAN NOT NULL DEFAULT FALSE
);
| true
|
10a5ba433c9f1507864c404e2b313284d200b868
|
SQL
|
mohd874/Projects
|
/java/Temp_design_change/web/WEB-INF/sql/dhp_db_script2.sql
|
UTF-8
| 5,391
| 3.4375
| 3
|
[] |
no_license
|
/*
Created 2/6/2006
Modified 3/18/2006
Project
Model
Company
Author
Version
Database mySQL 4.0
*/
drop table IF EXISTS sysuser;
drop table IF EXISTS shops;
drop table IF EXISTS services;
drop table IF EXISTS service_schedule;
drop table IF EXISTS rooms;
drop table IF EXISTS reservation_history;
drop table IF EXISTS facilities;
drop table IF EXISTS events;
drop table IF EXISTS event_schedule;
drop table IF EXISTS employees;
drop table IF EXISTS Customers;
drop table IF EXISTS customer_reservation;
Create table customer_reservation (
reservation_id Int NOT NULL,
arrival_date Date NOT NULL,
depart_date Date NOT NULL,
flight_number Varchar(5),
confirmation Char(1),
note Varchar(255),
credit_card_no Int NOT NULL,
credit_card_type Varchar(20) NOT NULL,
credit_card_exp_month Int NOT NULL,
credit_card_exp_year Int NOT NULL,
customer_id Int NOT NULL,
room_id Int NOT NULL,
Primary Key (reservation_id),
Index IX_Relationship1 (customer_id),
Foreign Key (customer_id) references Customers (customer_id) on delete no action on update no action,
Index IX_Relationship13 (room_id),
Foreign Key (room_id) references rooms (room_id) on delete no action on update no action
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table Customers (
customer_id Int NOT NULL,
title Char(20) NOT NULL,
fax Int,
e_mail Varchar(50) NOT NULL,
Primary Key (customer_id)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table employees (
employee_id Int NOT NULL,
job_title Varchar(20) NOT NULL,
marital_status Char(20) NOT NULL,
gender Char(20) NOT NULL,
years_of_exp Varchar(50) NOT NULL,
service_no Int NOT NULL,
Primary Key (employee_id),
Index IX_Relationship18 (service_no),
Foreign Key (service_no) references services (service_no) on delete no action on update no action
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table event_schedule (
appointment_no Int NOT NULL,
date_from Date NOT NULL,
date_to Date NOT NULL,
comment Varchar(255),
total_price Int,
description Varchar(255),
customer_id Int NOT NULL,
facility_no Int NOT NULL,
event_id Int NOT NULL,
Primary Key (appointment_no),
Index IX_Relationship10 (customer_id),
Foreign Key (customer_id) references Customers (customer_id) on delete no action on update no action,
Index IX_Relationship11 (facility_no),
Foreign Key (facility_no) references facilities (facility_no) on delete no action on update no action,
Index IX_Relationship20 (event_id),
Foreign Key (event_id) references events (event_id) on delete no action on update no action
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table events (
event_id Int NOT NULL,
event_type Varchar(15) NOT NULL,
event_desc Varchar(255) NOT NULL,
event_price Int NOT NULL,
Primary Key (event_id)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table facilities (
facility_no Int NOT NULL,
facility_type Varchar(20) NOT NULL,
facility_desc Char(255) NOT NULL,
Primary Key (facility_no)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table reservation_history (
reservation_id Int NOT NULL,
arrival_date Date NOT NULL,
depart_date Date NOT NULL,
flight_number Varchar(5),
confirmation Char(1),
note Varchar(255),
credit_card_no Int NOT NULL,
credit_card_type Varchar(20) NOT NULL,
credit_card_exp_month Int NOT NULL,
credit_card_exp_year Int NOT NULL,
customer_id Int NOT NULL,
room_id Int NOT NULL,
Primary Key (reservation_id)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table rooms (
room_id Int NOT NULL,
room_number Varchar(7) NOT NULL,
room_type Varchar(15) NOT NULL,
room_price Int,
room_view Varchar(20),
Primary Key (room_id)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table service_schedule (
order_id Int NOT NULL,
date Date NOT NULL,
time Time NOT NULL,
description Varchar(255),
job_done Char(20),
reservation_id Int NOT NULL,
employee_id Int NOT NULL,
service_no Int NOT NULL,
Primary Key (order_id),
Index IX_Relationship15 (reservation_id),
Foreign Key (reservation_id) references customer_reservation (reservation_id) on delete no action on update no action,
Index IX_Relationship19 (employee_id),
Foreign Key (employee_id) references employees (employee_id) on delete no action on update no action,
Index IX_Relationship21 (service_no),
Foreign Key (service_no) references services (service_no) on delete no action on update no action
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table services (
service_no Int NOT NULL,
service_type Varchar(20) NOT NULL,
service_desc Varchar(255) NOT NULL,
Primary Key (service_no)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table shops (
shop_no Int NOT NULL,
shop_name Varchar(20) NOT NULL,
shop_pic Varchar(50),
descr Varchar(255),
url Varchar(50),
Primary Key (shop_no)
) TYPE = MyISAM
ROW_FORMAT = Default;
Create table sysuser (
user_id Int NOT NULL,
user_name Varchar(20) NOT NULL,
password Varchar(20) NOT NULL,
name Varchar(20) NOT NULL,
surname Varchar(20) NOT NULL,
phone_number Int,
mobile_number Int NOT NULL,
address Varchar(100) NOT NULL,
passport_number Varchar(20) NOT NULL,
p_o_box Varchar(7),
nationality Varchar(20) NOT NULL,
Primary Key (user_id)
) TYPE = MyISAM
ROW_FORMAT = Default;
| true
|
56ccda32ae2468aa105c71ec90f878cda8d9c582
|
SQL
|
benzsnabenz/testyi
|
/php api/database/mydb.sql
|
UTF-8
| 3,680
| 3.046875
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 27, 2020 at 02:32 PM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.4.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `mydb`
--
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`product_id` int(11) NOT NULL,
`product_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`product_des` text COLLATE utf8_unicode_ci NOT NULL,
`product_img` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`qty` int(11) NOT NULL,
`create_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`product_id`, `product_name`, `product_des`, `product_img`, `qty`, `create_date`) VALUES
(1, 'Hormone Healthy Plus', 'An appropriate program for diagnosing adrenal fatigue...', 'image16.png', 1, '2020-09-27 11:47:42'),
(2, 'Hormone Healthy Plus', 'An appropriate program for diagnosing adrenal fatigue...', 'image1.png', 1, '2020-09-27 11:49:02'),
(3, 'Colon Hydrotherapy', 'Colon Hydrotherapy is a natural, safe and easy pro...', 'image5.png', 1, '2020-09-27 11:49:21'),
(4, 'Comprehensive Program (Male)', 'Bumrungrad offers Health Check-up & Screening servi...', 'image2.png', 1, '2020-09-27 11:49:31'),
(5, 'Egg Freezing Cycle Package', 'An appropriate program for diagnosing adrenal fatigue...', 'image3.png', 1, '2020-09-27 11:49:35'),
(6, 'myDNA Medication test', 'PGx panel - myDNA Medication test is a pharmacogenomics...', 'image3.png', 1, '2020-09-27 11:50:05'),
(7, 'Hormone Healthy Plus', 'An appropriate program for diagnosing adrenal fatigue...', 'image4.png', 1, '2020-09-27 11:50:07'),
(8, 'Hormone Healthy Plus', 'An appropriate program for diagnosing adrenal fatigue...', 'image4.png', 1, '2020-09-27 11:50:10');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`user_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`picture` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `user_id`, `username`, `picture`) VALUES
(1, '123', 'test', '123'),
(2, '1654986755', '<{BenzsaN}>', 'https://profile.line-scdn.net/0hwDVa6ZLpKGtrGAAyikdXPFddJgYcNi4jEy0wWBtMdghEK29pX3xiCBxNJFwRfTw7VypiBR4cdV1F');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`product_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
368d9dda3c9813637bad0c4390d2bfe0a8fb4258
|
SQL
|
Al-x-R/pg-DB_node-example
|
/db_commands/case_and_view.sql
|
UTF-8
| 2,132
| 4.5
| 4
|
[] |
no_license
|
SELECT *,
(CASE "isMale"
WHEN true THEN 'male'
WHEN false THEN 'female'
ELSE 'other'
END) as "GENDER"
FROM users;
SELECT brand,
(CASE
WHEN brand ILIKE 'iphone'
THEN 'apple'
ELSE 'other'
END) as "manufaturer"
FROM phones;
SELECT *,
(CASE
WHEN (extract('year' FROM age("birthday")) >= 65 AND "isMale") OR
extract('year' FROM age("birthday")) >= 60 AND not "isMale" THEN 'retiree'
WHEN extract('year' FROM age("birthday")) < 18 THEN 'underage'
ELSE 'middle age'
END) as "age status"
FROM users;
SELECT COALESCE(null, 12);
SELECT *
FROM users
WHERE users.id IN (SELECT "userId" FROM orders);
SELECT *
FROM orders
WHERE EXISTS(SELECT *
FROM phones_to_orders
WHERE EXISTS(SELECT * FROM phones WHERE brand ILIKE 'nokia'));
CREATE VIEW users_with_orders_count AS
(
SELECT u.*,
"lastName" || ' ' || "firstName" "full name",
(Case
WHEN "isMale" THEN 'MALE'
WHEN not "isMale" THEN 'FEMALE'
ELSE 'OTHER' END),
EXTRACT('year' FROM age(birthday)) "age",
count(o."userId"),
(sum(p.price * pto.quantity)) "orders total cost"
FROM users u
FULL JOIN orders o on u.id = o."userId"
LEFT JOIN phones_to_orders pto on o.id = pto."orderId"
LEFT JOIN phones p on pto."phoneId" = p.id
GROUP BY u.id
);
SELECT *
FROM users_with_orders_count;
CREATE VIEW phones_sold_count as
(
SELECT brand, model, price, sum(pto.quantity) "sold"
FROM phones p
JOIN phones_to_orders pto on p.id = pto."phoneId"
GROUP BY brand, model, price
ORDER BY "sold"
);
SELECT * FROM phones_sold_count;
SELECT o.id,
p.brand || ' ' || p.model "phone",
p.price,
pto.quantity,
sum(pto.quantity * p.id) OVER (PARTITION BY o.id) "order cost"
FROM orders o
JOIN phones_to_orders pto on o.id = pto."orderId"
JOIN phones p on p.id = pto."phoneId"
GROUP BY o.id, p.id, pto.quantity
| true
|
56f1321b94b6b04b745e51a0a4745a826093a0fb
|
SQL
|
doogn/query
|
/함수활용_20180515.sql
|
UHC
| 2,042
| 3.890625
| 4
|
[] |
no_license
|
--(P.23)
-- KOPO_CUSTOMERDATA ڵ10ڸ̴
-- 10ڸ ƴϸ ʿ 0 ä
-- ڵ 4ڸ ȣȭ * ó
--ؾմϴ.
SELECT
REPLACE(LPAD(CUSTOMERCODE, 10, '0')
,SUBSTR(CUSTOMERCODE, -4), '****')
AS CUSTOMERCODE_SECRET
FROM KOPO_CUSTOMERDATA;
SELECT
CONCAT(
SUBSTR(
LPAD(CUSTOMERCODE, 10, '0'), 0, 6
),'****'
) AS CUSTOMERCODE_SECRET
FROM KOPO_CUSTOMERDATA;
-- (P.26)
-- NUMBER_EXAMPLE
-- FIRST/NUMBER ȰϿ Ʒ
-- ϼ
SELECT
FIRST_NUMBER
,SECOND_NUMBER
,(FIRST_NUMBER / SECOND_NUMBER) AS AVG
,ROUND(FIRST_NUMBER / SECOND_NUMBER, 0) AS ROUND_EX
,CEIL(FIRST_NUMBER / SECOND_NUMBER) AS CEIL_EX
,FLOOR(FIRST_NUMBER / SECOND_NUMBER) AS FLLOR_EX
,MOD(FIRST_NUMBER, SECOND_NUMBER) AS MOD_EX
,POWER(FIRST_NUMBER, SECOND_NUMBER) AS POW_EX
FROM NUMBER_EXAMPLE;
-- (P.27)
-- RMSE_MAE_EXAMPLE2 ̺
-- ACCURACY = 1 ? ABS(-) / ȰϿ
-- Ȯ ϼ (Ҽ 2°ڸ ݿø)
SELECT
YEARWEEK
,ACTUAL
,FCST
,ROUND((1-ABS(FCST-ACTUAL)/FCST)*100, 2) AS ACCURACY
FROM RMSE_MAE_EXAMPLE2;
SELECT *
FROM(
SELECT
YEARWEEK
,ACTUAL
,FCST
,ROUND((1-ABS(FCST-ACTUAL)/FCST)*100, 2) AS ACCURACY
FROM RMSE_MAE_EXAMPLE2
)
WHERE 1=1
AND ACCURACY < 50; -- Ȯ 50% ̸
-- ¥ Լ
SELECT
SYSDATE, -- ¥
SYSDATE+2, -- 2
NEXT_DAY(SYSDATE,2), -- 2°() (1~7 => ~)
LAST_DAY(SYSDATE) -- ̹
FROM DUAL;
-- CASE .. WHEN
SELECT
YEARWEEK,
CASE WHEN QTY<1000 THEN 1000
WHEN QTY>1000 AND QTY < 10000 THEN 10000
ELSE 30000 END AS QTY
FROM KOPO_CHANNEL_SEASONALITY_NEW;
| true
|
2af818e683bdd45056e56299c6f5c006569cbc72
|
SQL
|
Jyawhurh/una
|
/modules/boonex/quoteofday/install/sql/uninstall.sql
|
UTF-8
| 637
| 3.234375
| 3
|
[
"MIT"
] |
permissive
|
SET @sName = 'bx_quoteofday';;
-- TABLES
DROP TABLE IF EXISTS `bx_quoteofday_internal`;
-- FORMS
DELETE FROM `sys_objects_form` WHERE `module` = @sName;
DELETE FROM `sys_form_displays` WHERE `module` = @sName;
DELETE FROM `sys_form_inputs` WHERE `module` = @sName;
DELETE FROM `sys_form_display_inputs` WHERE `display_name` IN ('bx_quoteofday_entry_add', 'bx_quoteofday_entry_edit');
-- STUDIO WIDGET
DELETE FROM `tp`, `tw`, `tpw`
USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = @sName;
| true
|
9777f4c772f68a5c345b6bb0a2f135d22b7a8165
|
SQL
|
LX1993728/mybatis_plus_practice
|
/mybatis-plus-multidb-transaction/src/main/resources/db/db2-schema-mysql.sql
|
UTF-8
| 274
| 2.6875
| 3
|
[] |
no_license
|
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`book_name` varchar(255) NOT NULL COMMENT '书名',
`author` varchar(255) NOT NULL COMMENT '作者',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
| true
|
24e275add6a62e91a0b411c9ed0f13d2e1d42b10
|
SQL
|
ricaralan/merchant
|
/documents/merchant.sql
|
UTF-8
| 19,103
| 3.453125
| 3
|
[] |
no_license
|
-- MySQL Script generated by MySQL Workbench
-- Sat 27 Jun 2015 03:32:15 PM CDT
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema merchant
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema merchant
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `merchant` DEFAULT CHARACTER SET latin1 ;
USE `merchant` ;
-- -----------------------------------------------------
-- Table `merchant`.`domiciliofiscal`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`domiciliofiscal` (
`idDomicilioFiscal` INT(11) NOT NULL AUTO_INCREMENT,
`calle` VARCHAR(45) NOT NULL,
`numExt` VARCHAR(45) NULL DEFAULT NULL,
`numInt` VARCHAR(5) NULL DEFAULT NULL,
`colonia` VARCHAR(45) NULL DEFAULT NULL,
`codigoPostal` VARCHAR(45) NULL DEFAULT NULL,
`localidad` VARCHAR(45) NULL DEFAULT NULL,
`municipio` VARCHAR(45) NULL DEFAULT NULL,
`estado` VARCHAR(45) NULL DEFAULT NULL,
`pais` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`idDomicilioFiscal`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`cliente`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`cliente` (
`idCliente` INT(11) NOT NULL AUTO_INCREMENT,
`rfcCliente` VARCHAR(15) NOT NULL,
`nombreCliente` VARCHAR(145) NOT NULL,
`telCliente` VARCHAR(15) NOT NULL,
`tel2Cliente` VARCHAR(15) NULL DEFAULT NULL,
`mailCliente` VARCHAR(45) NOT NULL,
`altaCliente` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`statusCliente` TINYINT(4) NULL DEFAULT NULL,
`domicilioFiscal_idDomicilioFiscal` INT(11) NOT NULL,
PRIMARY KEY (`idCliente`),
INDEX `fk_cliente_domicilioFiscal1_idx` (`domicilioFiscal_idDomicilioFiscal` ASC),
CONSTRAINT `fk_cliente_domicilioFiscal1`
FOREIGN KEY (`domicilioFiscal_idDomicilioFiscal`)
REFERENCES `merchant`.`domiciliofiscal` (`idDomicilioFiscal`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`regimenFiscal`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`regimenFiscal` (
`idregimenFiscal` INT NOT NULL,
`descripcionRegimenFiscal` VARCHAR(50) NOT NULL,
PRIMARY KEY (`idregimenFiscal`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `merchant`.`empresa`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`empresa` (
`idEmpresa` INT(11) NOT NULL AUTO_INCREMENT,
`nombreEmpresa` VARCHAR(45) NOT NULL,
`rfcEmpresa` VARCHAR(15) NOT NULL,
`logoEmpresa` VARCHAR(45) NULL DEFAULT NULL,
`telEmpresa` VARCHAR(15) NULL DEFAULT NULL,
`tel2Empresa` VARCHAR(15) NULL DEFAULT NULL,
`mailEmpresa` VARCHAR(45) NULL DEFAULT NULL,
`webEmpresa` VARCHAR(45) NULL DEFAULT NULL,
`altaEmpresa` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`regimenFiscal_idregimenFiscal` INT NOT NULL,
PRIMARY KEY (`idEmpresa`, `regimenFiscal_idregimenFiscal`),
INDEX `fk_empresa_regimenFiscal1_idx` (`regimenFiscal_idregimenFiscal` ASC),
CONSTRAINT `fk_empresa_regimenFiscal1`
FOREIGN KEY (`regimenFiscal_idregimenFiscal`)
REFERENCES `merchant`.`regimenFiscal` (`idregimenFiscal`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`sucursal`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`sucursal` (
`idSucursal` INT(11) NOT NULL AUTO_INCREMENT,
`nombreSucursal` VARCHAR(45) NULL DEFAULT NULL,
`empresa_idEmpresa` INT(11) NOT NULL,
`domiciliofiscal_idDomicilioFiscal` INT(11) NOT NULL,
PRIMARY KEY (`idSucursal`, `empresa_idEmpresa`, `domiciliofiscal_idDomicilioFiscal`),
INDEX `fk_sucursal_empresa1_idx` (`empresa_idEmpresa` ASC),
INDEX `fk_sucursal_domiciliofiscal1_idx` (`domiciliofiscal_idDomicilioFiscal` ASC),
CONSTRAINT `fk_sucursal_domiciliofiscal1`
FOREIGN KEY (`domiciliofiscal_idDomicilioFiscal`)
REFERENCES `merchant`.`domiciliofiscal` (`idDomicilioFiscal`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_sucursal_empresa1`
FOREIGN KEY (`empresa_idEmpresa`)
REFERENCES `merchant`.`empresa` (`idEmpresa`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`tipoEmpleado`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`tipoEmpleado` (
`idtipoEmpleado` INT(2) NOT NULL AUTO_INCREMENT,
`tipoEmpleado` VARCHAR(25) NULL DEFAULT NULL,
PRIMARY KEY (`idtipoEmpleado`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`usuario` (
`idUsuario` INT(11) NOT NULL AUTO_INCREMENT,
`nombreUsuario` VARCHAR(45) NOT NULL,
`passwordUsuario` VARCHAR(45) NOT NULL,
`statusUsuario` TINYINT(4) NOT NULL,
PRIMARY KEY (`idUsuario`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`empleado`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`empleado` (
`idEmpleado` INT(11) NOT NULL AUTO_INCREMENT,
`rfcEmpleado` VARCHAR(25) NOT NULL,
`tipoEmpleado_idtipoEmpleado` INT(2) NOT NULL,
`nombreEmpleado` VARCHAR(45) NOT NULL,
`apellidosEmpleado` VARCHAR(60) NOT NULL,
`telefonoEmpleado` VARCHAR(45) NULL DEFAULT NULL,
`mailEmpleado` VARCHAR(45) NULL DEFAULT NULL,
`salarioDiarioEmpleado` DOUBLE NOT NULL,
`diasLaboralesEmpleado` INT(11) NULL DEFAULT NULL,
`altaEmpleado` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`usuario_idUsuario` INT(11) NOT NULL,
`domicilioFiscal_idDomicilioFiscal` INT(11) NOT NULL,
`sucursal_idSucursal` INT(11) NOT NULL,
`bajaEmpleado` TIMESTAMP NULL DEFAULT NULL,
`statusEmpleado` TINYINT(4) NULL DEFAULT NULL,
PRIMARY KEY (`idEmpleado`, `sucursal_idSucursal`),
INDEX `fk_empleado_usuario1_idx` (`usuario_idUsuario` ASC),
INDEX `fk_empleado_domicilioFiscal1_idx` (`domicilioFiscal_idDomicilioFiscal` ASC),
INDEX `fk_empleado_sucursal1_idx` (`sucursal_idSucursal` ASC),
INDEX `fk_empleado_tipoEmpleado1_idx` (`tipoEmpleado_idtipoEmpleado` ASC),
CONSTRAINT `fk_empleado_domicilioFiscal1`
FOREIGN KEY (`domicilioFiscal_idDomicilioFiscal`)
REFERENCES `merchant`.`domiciliofiscal` (`idDomicilioFiscal`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_empleado_sucursal1`
FOREIGN KEY (`sucursal_idSucursal`)
REFERENCES `merchant`.`sucursal` (`idSucursal`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_empleado_tipoEmpleado1`
FOREIGN KEY (`tipoEmpleado_idtipoEmpleado`)
REFERENCES `merchant`.`tipoEmpleado` (`idtipoEmpleado`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_empleado_usuario1`
FOREIGN KEY (`usuario_idUsuario`)
REFERENCES `merchant`.`usuario` (`idUsuario`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`proveedor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`proveedor` (
`idProveedor` INT(11) NOT NULL AUTO_INCREMENT,
`rfcProveedor` VARCHAR(15) NOT NULL,
`nombreProveedor` VARCHAR(45) NOT NULL,
`telProveedor` VARCHAR(15) NULL DEFAULT NULL,
`tel2Proveedor` VARCHAR(15) NULL DEFAULT NULL,
`mailProveedor` VARCHAR(45) NULL DEFAULT NULL,
`domicilioFiscal_idDomicilioFiscal` INT(11) NOT NULL,
PRIMARY KEY (`idProveedor`),
INDEX `fk_proveedor_domicilioFiscal1_idx` (`domicilioFiscal_idDomicilioFiscal` ASC),
CONSTRAINT `fk_proveedor_domicilioFiscal1`
FOREIGN KEY (`domicilioFiscal_idDomicilioFiscal`)
REFERENCES `merchant`.`domiciliofiscal` (`idDomicilioFiscal`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`compra`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`compra` (
`idCompra` INT(11) NOT NULL AUTO_INCREMENT,
`fechaCompra` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`totalCompra` FLOAT NOT NULL,
`tipoPagoCompra` VARCHAR(10) NOT NULL,
`statusCompra` VARCHAR(10) NOT NULL,
`statusLiquidezCompra` TINYINT(4) NOT NULL,
`fechaPagoLimiteCompra` DATE NULL DEFAULT NULL,
`numeroPagos` INT(11) NULL DEFAULT NULL,
`proveedor_idProveedor` INT(11) NOT NULL,
`empleado_idEmpleado` INT(11) NOT NULL,
PRIMARY KEY (`idCompra`),
INDEX `fk_compra_proveedor1_idx` (`proveedor_idProveedor` ASC),
INDEX `fk_compra_empleado1_idx` (`empleado_idEmpleado` ASC),
CONSTRAINT `fk_compra_empleado1`
FOREIGN KEY (`empleado_idEmpleado`)
REFERENCES `merchant`.`empleado` (`idEmpleado`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_compra_proveedor1`
FOREIGN KEY (`proveedor_idProveedor`)
REFERENCES `merchant`.`proveedor` (`idProveedor`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`impuesto`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`impuesto` (
`idImpuesto` INT(2) NOT NULL AUTO_INCREMENT,
`codigoImpuesto` VARCHAR(8) NULL DEFAULT NULL,
`descripcionImpuesto` VARCHAR(50) NULL DEFAULT NULL,
`valorImpuesto` FLOAT NULL DEFAULT NULL,
PRIMARY KEY (`idImpuesto`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`linea`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`linea` (
`idLinea` INT(2) NOT NULL AUTO_INCREMENT,
`codigoLinea` VARCHAR(8) NULL DEFAULT NULL,
`descripcionLinea` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`idLinea`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`tipoUnidad`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`tipoUnidad` (
`idtipoUnidad` INT(2) NOT NULL AUTO_INCREMENT,
`codigoUnidad` VARCHAR(8) NULL DEFAULT NULL,
`descripcionUnidad` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`idtipoUnidad`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`producto`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`producto` (
`idCodigoBarraProducto` VARCHAR(20) NOT NULL,
`descripcionProducto` VARCHAR(95) NULL DEFAULT NULL,
`existenciaProducto` FLOAT NOT NULL,
`stockMinimoProducto` FLOAT NOT NULL,
`precioVenta` FLOAT NOT NULL,
`tipoUnidad_idtipoUnidad` INT(2) NOT NULL,
`impuesto_idImpuesto` INT(2) NOT NULL,
`statusProducto` TINYINT(4) NULL DEFAULT NULL,
`linea_idLinea` INT(11) NOT NULL,
PRIMARY KEY (`idCodigoBarraProducto`, `tipoUnidad_idtipoUnidad`, `impuesto_idImpuesto`, `linea_idLinea`),
INDEX `fk_producto_tipoUnidad1_idx` (`tipoUnidad_idtipoUnidad` ASC),
INDEX `fk_producto_impuesto1_idx` (`impuesto_idImpuesto` ASC),
INDEX `fk_producto_linea1_idx` (`linea_idLinea` ASC),
CONSTRAINT `fk_producto_impuesto1`
FOREIGN KEY (`impuesto_idImpuesto`)
REFERENCES `merchant`.`impuesto` (`idImpuesto`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_producto_linea1`
FOREIGN KEY (`linea_idLinea`)
REFERENCES `merchant`.`linea` (`idLinea`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_producto_tipoUnidad1`
FOREIGN KEY (`tipoUnidad_idtipoUnidad`)
REFERENCES `merchant`.`tipoUnidad` (`idtipoUnidad`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`detallecompra`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`detallecompra` (
`producto_idCodigoBarraProducto` VARCHAR(20) NOT NULL,
`compra_idCompra` INT(11) NOT NULL,
`costoUnitarioProducto` FLOAT NULL DEFAULT NULL,
`cantidad` FLOAT NOT NULL,
PRIMARY KEY (`producto_idCodigoBarraProducto`, `compra_idCompra`),
INDEX `fk_producto_has_compra_compra1_idx` (`compra_idCompra` ASC),
INDEX `fk_producto_has_compra_producto1_idx` (`producto_idCodigoBarraProducto` ASC),
CONSTRAINT `fk_producto_has_compra_compra1`
FOREIGN KEY (`compra_idCompra`)
REFERENCES `merchant`.`compra` (`idCompra`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_producto_has_compra_producto1`
FOREIGN KEY (`producto_idCodigoBarraProducto`)
REFERENCES `merchant`.`producto` (`idCodigoBarraProducto`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`detalleproducto`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`detalleproducto` (
`proveedor_idProveedor` INT(11) NOT NULL,
`producto_idCodigoBarraProducto` VARCHAR(20) NOT NULL,
`precioCompra` FLOAT NOT NULL,
PRIMARY KEY (`proveedor_idProveedor`, `producto_idCodigoBarraProducto`),
INDEX `fk_proveedor_has_producto_producto1_idx` (`producto_idCodigoBarraProducto` ASC),
INDEX `fk_proveedor_has_producto_proveedor1_idx` (`proveedor_idProveedor` ASC),
CONSTRAINT `fk_proveedor_has_producto_producto1`
FOREIGN KEY (`producto_idCodigoBarraProducto`)
REFERENCES `merchant`.`producto` (`idCodigoBarraProducto`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_proveedor_has_producto_proveedor1`
FOREIGN KEY (`proveedor_idProveedor`)
REFERENCES `merchant`.`proveedor` (`idProveedor`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`tipoComprobante`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`tipoComprobante` (
`idTipoComprobante` INT(2) NOT NULL AUTO_INCREMENT,
`codigoTipo` VARCHAR(8) NULL DEFAULT NULL,
`descripcionComprobante` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`idTipoComprobante`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`venta`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`venta` (
`idVenta` INT(11) NOT NULL AUTO_INCREMENT,
`fechaVenta` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`subTotalVenta` FLOAT NOT NULL,
`ivaVenta` FLOAT NOT NULL,
`totalVenta` FLOAT NOT NULL,
`estatusVenta` VARCHAR(10) NOT NULL,
`tipoVenta` VARCHAR(10) NULL DEFAULT NULL,
`cliente_idCliente` INT(11) NOT NULL,
`empleado_idEmpleado` INT(11) NOT NULL,
`tipoComprobante_idTipoComprobante` INT(2) NOT NULL,
PRIMARY KEY (`idVenta`, `tipoComprobante_idTipoComprobante`),
INDEX `fk_venta_cliente1_idx` (`cliente_idCliente` ASC),
INDEX `fk_venta_empleado1_idx` (`empleado_idEmpleado` ASC),
INDEX `fk_venta_tipoComprobante1_idx` (`tipoComprobante_idTipoComprobante` ASC),
CONSTRAINT `fk_venta_cliente1`
FOREIGN KEY (`cliente_idCliente`)
REFERENCES `merchant`.`cliente` (`idCliente`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_venta_empleado1`
FOREIGN KEY (`empleado_idEmpleado`)
REFERENCES `merchant`.`empleado` (`idEmpleado`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_venta_tipoComprobante1`
FOREIGN KEY (`tipoComprobante_idTipoComprobante`)
REFERENCES `merchant`.`tipoComprobante` (`idTipoComprobante`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`detalleventa`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`detalleventa` (
`producto_idCodigoBarraProducto` VARCHAR(20) NOT NULL,
`venta_idVenta` INT(11) NOT NULL,
`cantidad` FLOAT NOT NULL,
PRIMARY KEY (`producto_idCodigoBarraProducto`, `venta_idVenta`),
INDEX `fk_venta_has_producto_producto1_idx` (`producto_idCodigoBarraProducto` ASC),
INDEX `fk_venta_has_producto_venta1_idx` (`venta_idVenta` ASC),
CONSTRAINT `fk_venta_has_producto_producto1`
FOREIGN KEY (`producto_idCodigoBarraProducto`)
REFERENCES `merchant`.`producto` (`idCodigoBarraProducto`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_venta_has_producto_venta1`
FOREIGN KEY (`venta_idVenta`)
REFERENCES `merchant`.`venta` (`idVenta`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `merchant`.`pagosCompra`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `merchant`.`pagosCompra` (
`idPagosCompra` INT(11) NOT NULL AUTO_INCREMENT,
`montoPago` VARCHAR(45) NULL DEFAULT NULL,
`fechaPagoCompra` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`compra_idCompra` INT(11) NOT NULL,
PRIMARY KEY (`idPagosCompra`, `compra_idCompra`),
INDEX `fk_pagosCompra_compra1_idx` (`compra_idCompra` ASC),
CONSTRAINT `fk_pagosCompra_compra1`
FOREIGN KEY (`compra_idCompra`)
REFERENCES `merchant`.`compra` (`idCompra`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'merchant'@'%' IDENTIFIED BY PASSWORD '*E12CD91AC8FA1DC769505B9F283FAD0EC04AEE24' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON `merchant`.* TO 'merchant'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
| true
|
c9af7c29a6dd23544cec3e41f781aba556556d8d
|
SQL
|
GoSteven/9321-Assignment
|
/MM_Movie_ass3.sql
|
UTF-8
| 28,648
| 3.359375
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 3.3.10
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 31, 2011 at 01:48 AM
-- Server version: 5.5.11
-- PHP Version: 5.3.4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `MM_Movie`
--
-- --------------------------------------------------------
--
-- Table structure for table `Booking`
--
DROP TABLE IF EXISTS `Booking`;
CREATE TABLE IF NOT EXISTS `Booking` (
`BookingId` varchar(250) NOT NULL,
`UserId` varchar(250) NOT NULL,
`ShowTimeId` varchar(250) NOT NULL,
`NumOfTicket` int(32) NOT NULL DEFAULT '1',
PRIMARY KEY (`BookingId`),
KEY `UserId` (`UserId`),
KEY `ShowTimeId` (`ShowTimeId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Booking`
--
-- --------------------------------------------------------
--
-- Table structure for table `Cinema`
--
DROP TABLE IF EXISTS `Cinema`;
CREATE TABLE IF NOT EXISTS `Cinema` (
`CinemaId` varchar(250) NOT NULL,
`CinemaName` varchar(500) NOT NULL,
`Location` varchar(500) NOT NULL,
`SeatingCapacity` int(11) NOT NULL,
`Amenities` int(11) NOT NULL,
PRIMARY KEY (`CinemaId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Cinema`
--
INSERT INTO `Cinema` (`CinemaId`, `CinemaName`, `Location`, `SeatingCapacity`, `Amenities`) VALUES
('38F25AC6-CFC8-BF3B-70F9-E9372F2693D4', 'Event-Burbood', 'Burbood', 40, 7),
('68D73B31-1EF5-E65B-0CA0-D53498F462E6', 'Event', 'Town Hall', 100, 3),
('EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'Event-BondiJunction', 'Bondi Junction', 200, 3);
-- --------------------------------------------------------
--
-- Table structure for table `Comment`
--
DROP TABLE IF EXISTS `Comment`;
CREATE TABLE IF NOT EXISTS `Comment` (
`CommentId` varchar(250) NOT NULL,
`MovieId` varchar(250) NOT NULL,
`UserId` varchar(250) NOT NULL,
`Rating` int(32) NOT NULL,
`CommentContent` varchar(1000) NOT NULL,
`CommentTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`CommentId`),
KEY `MovieId` (`MovieId`),
KEY `UserId` (`UserId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Comment`
--
INSERT INTO `Comment` (`CommentId`, `MovieId`, `UserId`, `Rating`, `CommentContent`, `CommentTime`) VALUES
('31AD8555-E4D2-19FF-4805-78E6DC38D68F', '987873AD-0EE2-D42F-906E-4227646BB23C', 'B85AD097-6437-4D70-E825-F3774896DAB2', 0, 'HaHa', '2011-05-08 02:07:33'),
('4DF84DD7-160C-2CA6-2033-881668734D31', '987873AD-0EE2-D42F-906E-4227646BB23C', 'B85AD097-6437-4D70-E825-F3774896DAB2', 2, 'HHhhH', '2011-05-08 01:43:35'),
('706872D7-772D-52E5-0299-02E0B5B968E6', '6DD8C5EF-8E78-917C-A39F-67564C9F8005', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 2, 'like it', '2011-05-09 20:53:15'),
('908E27C4-4748-2121-DF38-6ABF7B281F59', '987873AD-0EE2-D42F-906E-4227646BB23C', 'B85AD097-6437-4D70-E825-F3774896DAB2', 2, 'HHhhH', '2011-05-08 01:42:19'),
('9CDE2625-1903-5747-8EBA-20FBA6AD33CC', '6DD8C5EF-8E78-917C-A39F-67564C9F8005', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 2, 'This is a good movie!!!', '2011-05-08 21:09:03'),
('AAEE1F31-78F3-CDF2-6FE0-5F0BB70DF34E', '987873AD-0EE2-D42F-906E-4227646BB23C', 'B85AD097-6437-4D70-E825-F3774896DAB2', 2, 'HHhhH', '2011-05-08 01:29:59');
-- --------------------------------------------------------
--
-- Table structure for table `FriendInvitation`
--
DROP TABLE IF EXISTS `FriendInvitation`;
CREATE TABLE IF NOT EXISTS `FriendInvitation` (
`InvitationId` varchar(250) NOT NULL,
`ToUser` varchar(250) NOT NULL,
`FromUser` varchar(250) NOT NULL,
`Message` varchar(500) DEFAULT NULL,
`IsConfirmed` tinyint(1) NOT NULL,
PRIMARY KEY (`InvitationId`),
KEY `ToUser` (`ToUser`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `FriendInvitation`
--
INSERT INTO `FriendInvitation` (`InvitationId`, `ToUser`, `FromUser`, `Message`, `IsConfirmed`) VALUES
('0BA3BD84-C45B-62E1-C619-BC847EE9C03C', '6D83531E-3563-CA8C-EFC3-BF51C20709B1', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 'pls', 1),
('18D977D9-F12F-E46F-2232-947CF58D1F3D', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57', 'hi', 1),
('3F7A847A-D2DD-1E83-30C9-DB03934DEEC4', '8E976A10-6AA2-7765-9B82-B671018C8C57', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 'kokokoo', 1),
('5DF63AEC-DB6D-661A-48A5-52AB7B782F56', '6D83531E-3563-CA8C-EFC3-BF51C20709B1', '8E976A10-6AA2-7765-9B82-B671018C8C57', 'pls be my friend', 1),
('86A37C4A-CF0C-A66D-5859-48D8D2A68803', '8E976A10-6AA2-7765-9B82-B671018C8C57', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 'be my ', 1),
('919F3E5F-E971-082F-7955-9F8304B8E9D0', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57', 'hi', 1),
('D437F5B3-5F76-28A0-64A8-21AD4C981CF9', '8E976A10-6AA2-7765-9B82-B671018C8C57', '2C168FB2-537F-FE63-751E-72E1D9DFB349', 'dodododdodo', 1),
('F8B37F70-6242-4A8C-95ED-80D90ACD4CE2', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '6D83531E-3563-CA8C-EFC3-BF51C20709B1', 'Hi, pls be my friend', 1);
-- --------------------------------------------------------
--
-- Table structure for table `Friends`
--
DROP TABLE IF EXISTS `Friends`;
CREATE TABLE IF NOT EXISTS `Friends` (
`FriendsID` varchar(250) NOT NULL,
`UserA` varchar(250) NOT NULL,
`UserB` varchar(250) NOT NULL,
PRIMARY KEY (`FriendsID`),
KEY `UserA` (`UserA`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Friends`
--
INSERT INTO `Friends` (`FriendsID`, `UserA`, `UserB`) VALUES
('D2E6DDF1-77FF-F279-C92B-C2FC7381F76E', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57');
-- --------------------------------------------------------
--
-- Table structure for table `Movies`
--
DROP TABLE IF EXISTS `Movies`;
CREATE TABLE IF NOT EXISTS `Movies` (
`MovieID` varchar(250) NOT NULL,
`MovieTitle` varchar(500) NOT NULL,
`Poster` varchar(500) DEFAULT NULL,
`YoutubeLink` varchar(1000) DEFAULT NULL,
`Actors` varchar(500) DEFAULT NULL,
`Genre` int(32) DEFAULT NULL,
`Director` varchar(500) DEFAULT NULL,
`ShortSynopsis` varchar(500) DEFAULT NULL,
`AgeRating` int(32) DEFAULT NULL,
`ReleaseDate` date DEFAULT NULL,
`ExpireDate` date DEFAULT NULL,
PRIMARY KEY (`MovieID`),
KEY `ReleaseDate` (`ReleaseDate`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Movies`
--
INSERT INTO `Movies` (`MovieID`, `MovieTitle`, `Poster`, `YoutubeLink`, `Actors`, `Genre`, `Director`, `ShortSynopsis`, `AgeRating`, `ReleaseDate`, `ExpireDate`) VALUES
('093C0B41-19B8-88D5-5C33-3284A612F469', 'Dharti', '1304936478859Dharti.jpg', 'Dharti is family drama set in Punjab on the backdrop of Punjab Politics. Prem Chopra plays the character of Baljit Singh Wadala, the head of ruling party in Punjab and he has two sons. The elder son Vikramjit Singh Wadala played by Randeep Arya is following his father''s footsteps and is a prominent Political leader, while the younger son Jasdeep Singh Wadala played by Jimmy Sheirgill is a Squadron Leader in the Indian Air Force.', 'Jimmy Dhergil', 2, 'Eros', '<iframe width="560" height="349" src="http://www.youtube.com/embed/uMnEduDrWAM" frameborder="0" allowfullscreen></iframe>', 4, '2011-05-12', '2011-05-31'),
('2451C98B-8F87-F8D3-7D39-BB220BB42D7B', 'thor', '1304939401748thor.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/JOddp-nlNvQ" frameborder="0" allowfullscreen></iframe>', 'Chris Hemsworth, Anthony Hopkins', 520, 'Kenneth Branagh', 'Thor is a powerful but arrogant warrior from another world whose reckless actions reignite an ancient war. He is cast down to Earth and forced to live among humans as punishment. Once here, Thor learns what it takes to be a true hero when the most dangerous villain of his world sends the darkest forces of Asgard to invade Earth.', 4, '2011-06-12', '2011-06-30'),
('2686E2E9-2D76-A24A-F651-09CF9E0A3010', 'inside job', '1304937794615insidejob.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/pZm7M1vn15w" frameborder="0" allowfullscreen></iframe>', 'Matt Damon, William Ackman', 182, 'Charles Ferguson', 'From Academy AwardÆ nominated filmmaker, Charles Ferguson (ìNo End In Sightî), comes INSIDE JOB, the first film to expose the shocking truth behind the economic crisis of 2008. The global financial meltdown, at a cost of over $20 trillion, resulted in millions of people losing their homes and jobs.', 4, '2011-06-01', '2011-06-30'),
('3CA85282-488C-288B-2C35-A668C33C3E64', 'Source Code', '1304939730932sourcecode.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/_3QkJ_a1nlw" frameborder="0" allowfullscreen></iframe>', 'Jake Gyllenhaal, Michelle Monaghan', 2, 'Duncan Jones', 'When decorated soldier Captain Colter Stevens (Jake Gyllenhaal) wakes up in the body of an unknown man, he discovers he''s part of a mission to find the bomber of a Chicago commuter train. In an assignment unlike any he''s ever known, he learns he''s part of a government experiment called the "Source Code," a program that enables him to cross over into another man''s identity in the last 8 minutes of his life.', 2, '2011-06-18', '2011-07-17'),
('3D41CC2C-6EB2-C95F-410C-899DA86A2371', 'just go with it', '1304938810729justgowithit.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/Jz5Ubqhru7g" frameborder="0" allowfullscreen></iframe>', 'Adam Sandler, Jennifer Aniston', 102, 'Dennis Dugan', 'In Just Go With It, a plastic surgeon, romancing a much younger schoolteacher, enlists his loyal assistant to pretend to be his soon to be ex-wife, in order to cover up a careless lie. When more lies backfire, the assistant''s kids become involved, and everyone heads off for a weekend in Hawaii that will change all their lives.', 4, '2011-06-08', '2011-06-30'),
('41D40658-3EA0-C37E-30A4-6E8A351D26E5', 'The whole', '1304937794615insidejob.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/JOddp-nlNvQ" frameborder="0" allowfullscreen></iframe> ', 'ads', 108, 'Harry', 'sAssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 1, '2011-05-28', '2011-05-31'),
('4C0AFE64-650C-8131-D9E3-F7298AF358F7', 'Limitless', '1304938696235limitless.jpg', '<iframe width="425" height="349" src="http://www.youtube.com/embed/THE_hhk1Gzc" frameborder="0" allowfullscreen></iframe>', 'Bradley Cooper, Robert De Niro, Abbie Cornish, Anna Friel', 102, 'Neil Burger', 'Based on the novel by Alan Glynn, ìLimitlessî is an exciting ìWhat if?î story that unveils a designer drug that could make you rich and powerful. Eddie (Bradley Cooper) is a down and out New York writer until he comes to possess a pill that gives him the ability to access the full capacity of his brain. Soon Eddie realizes the use of his newfound superior intelligence and success comes at a heavy price as mysterious antagonists pursue him and dangers of the amazing new drug are revealed.', 4, '2011-06-03', '2011-06-30'),
('4D45650C-B521-D3B2-856B-D6F22BC5337D', 'Justin bieber - Never Say Never', '1304940024526JS-neversaynever.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/COJCN3Mhr14" frameborder="0" allowfullscreen></iframe>', 'Justin Bieber', 102, 'Jon Chu', 'Biopic featuring special concert footage\r\nThe exhilarating story of an everyday kid''s struggle to realize his dreams, Never Say Never gives an intimate and exclusive behind-the-scenes look at Justin Bieber''s fascinating rise to fame thanks to the love, support and collaboration of a new generation of fans.', 1, '2011-05-21', '2011-06-30'),
('6DD8C5EF-8E78-917C-A39F-67564C9F8005', '3d - Hoodwinked Too: Hood Vs Evil', '13048509685673d - Hoodwinked Too: Hood Vs Evil.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/hvLpPJs15rU" frameborder="0" allowfullscreen></iframe>', 'Glenn Close, Cheech & Chong, Bill Hader', 22, 'Mike Disa', 'From the team that brought you HOODWINKED, the comedic portrayal of the fairy tale Red Riding Hood, comes the all-new animated family comedy HOODWINKED TOO! HOOD VS. EVIL in 3D. The sequel finds our heroine, Red (Hayden Panettiere), training with a mysterious covert group called the Sisters of the Hood.', 1, '2011-05-09', '2012-05-17'),
('73826263-45AD-68C4-CB8D-78EF64E9F4BE', 'Another Year', '1304851248681Another Year.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/yypx-Tz8NzU" frameborder="0" allowfullscreen></iframe>', 'Jim Broadbent , Lesley Manville', 134, 'Mike Leigh', 'Married couple Gerri (Ruth Sheen) and Tom (Jim Broadbent) have managed to remain blissfully happy into their autumn years. ANOTHER YEAR takes an in-depth look at their lives over the course of one average set of seasons ñ from the highs and lows of their friends (Lesley Manville and Peter Wight), to their own familyís ups and downs.', 1, '2011-05-09', '2012-05-18'),
('7485CE5F-3E06-5FD7-4573-CAD26977A23B', 'hop', '1304937430275hop.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/HExP4izD358" frameborder="0" allowfullscreen></iframe>', 'Russell Brand, James Marsden', 0, 'Tim Hill', 'Blending state of the art animation with live action, Hop is a comedy about E.B. (voiced by Russell Brand), the teenage son of the Easter Bunny. On the eve of taking over the family business, E.B. leaves for Hollywood in pursuit of his dream of becoming a drummer. He encounters Fred (James Marsden).', 1, '2011-05-26', '2011-06-30'),
('821F85C4-9AD3-5E25-04CB-88EA45FEAD95', 'High Society', '1304937336972highsociety.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/tBnUtmplc7w" frameborder="0" allowfullscreen></iframe>', 'Bing Crosby, Grace Kelly', 289, 'Charles Walters', 'C.K. Dexter-Haven, a successful popular jazz musician, lives in a mansion near his ex-wife''s Tracy Lord''s family estate. She is on the verge of marrying a man blander and safer than Dex, who tries to win Tracy''s heart again. Mike Connor, an undercover tabloid reporter, also falls for Tracy while covering the nuptials for Spy magazine. Tracy must choose between the three men as she discovers that "safe" can mean "deadly dull" when it comes to husbands and life.', 2, '2011-05-27', '2011-06-30'),
('829347A6-2188-A9DD-02AC-40C825FB53F2', 'never let me go', '1304936609579neverletmego.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/EUPsKjdtQSM" frameborder="0" allowfullscreen></iframe>', 'Keira Knightley, Carey Mulligan, Andrew Garfield', 0, 'Mark Romanek', 'In his highly acclaimed novel Never Let Me Go, Kazuo Ishiguro (The Remains of the Day) created a remarkable story of love, loss and hidden truths. In it he posed the fundamental question: What makes us human? Now, director Mark Romanek (ONE HOUR PHOTO), writer Alex Garland and DNA Films, bring Ishiguro''s hauntingly poignant and emotional story to the screen.', 4, '2011-05-12', '2011-05-31'),
('91825483-301C-ABF5-8B60-8803CA37B30E', 'Water For Elephants', '1304939582687waterforelephants.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/OOPHFQZ5aiM" frameborder="0" allowfullscreen></iframe>', 'Reese Witherspoon, Robert Pattinson', 146, 'Francis Lawrence', 'During the Great Depression, Jacob, a penniless 23-year-old veterinary school student, parlays his expertise with animals into a job with a second-rate traveling circus. He falls in love with Marlena, one of the show''s star performers, but their romance is complicated by Marlena''s husband, the charismatic but unbalanced circus boss.', 4, '2011-06-03', '2011-06-30'),
('B5B72909-23A5-E299-62A5-EC770DDB6444', 'paul', '1304938891637paul.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/KdHUQtnJsyQ" frameborder="0" allowfullscreen></iframe>', 'Nick Frost, Simon Pegg, Seth Rogen, Jane Lynch', 11, 'Greg Mottola', 'Simon Pegg and Nick Frost (Hot Fuzz, Shaun of the Dead) reunite for the comedy adventure Paul as two sci-fi geeks whose pilgrimage takes them to Americaís UFO heartland. While there, they accidentally meet an alien who brings them on an insane road trip that alters their universe forever.', 8, '2011-06-09', '2011-06-30'),
('BDF28154-D726-96D4-80DC-DB9C7B91F07F', 'diary Of A Wimpy Kid 2: Rodrick Rules', '1304937209168Diraryofawimpykid2.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/ZbqqYuG1TCM" frameborder="0" allowfullscreen></iframe>', 'Zachary Gordon, Devon Bostick', 0, 'David Bowers', 'Greg Heffley, the kid who made ìwimpyî cool, is back in an all-new family comedy based on the best-selling illustrated novel by Jeff Kinney, one of a series that has thus far sold 28 million books. As he begins seventh grade, Greg tries to score points with a pretty new girl in school while honoring his momís request to spend quality time with his older brother ñ and chief tormentor -- Rodrick.', 1, '2011-05-18', '2011-05-31'),
('C5E236DC-E239-74FE-FCE6-A65F644AF958', 'rio', '1304939305907rio.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/d1PokzTa9Yo" frameborder="0" allowfullscreen></iframe>', 'Jesse Eisenberg, Anne Hathaway', 100, 'Carlos Saldanha', 'RIO is a 3-D animation feature from the makers of the ìIce Ageî films. Set in the magnificent city of Rio de Janeiro and the lush rainforest of Brazil, the comedy-adventure centers on Blu, a rare macaw who thinks he is the last of his kind. When Blu discovers thereís another ñ and that sheís a she ñ he leaves the comforts of his cage in small town Minnesota and heads to Rio.', 1, '2011-05-23', '2011-06-30'),
('CEDE9613-B308-27BD-870D-5B9726CD25CE', 'babies', '1304936329725Babies.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/QkytlvAEE2k" frameborder="0" allowfullscreen></iframe>', 'Bayar, Hattie, Mari', 36, 'Thomas BalmËs', 'The adventure of a lifetime beginsÖ with BABIES.\r\nDirected by award-winning filmmaker Thomas BalmËs, from an original idea by producer Alain Chabat, this visually stunning film follows four babies during their first year on earth ó from first breath to first steps.', 1, '2011-05-12', '2011-05-31'),
('D06EADEE-F8C7-1D86-A417-5C4B9C7A654C', 'rango', '1304938988238rango.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/k-OOfW6wWyQ" frameborder="0" allowfullscreen></iframe>', 'Johnny Depp, Timothy Olyphant', 22, 'Gore Verbinski', 'Rango is the story of a lonely chameleon who can play any role, yet doesnít know who he is. His journey takes him from the solitude of a terrarium to the vastness of the Mojave desert where he adopts the persona of vigilante lawman Rango, convincing the occupants of the town of Dirt that he is the solution to their looming hydration problem.', 1, '2011-06-17', '2011-06-30'),
('EBB9938D-96ED-C90B-737C-D09FD1D692A4', 'scream 4', '1304936948538scream4.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/D5TsZ6iyaH4" frameborder="0" allowfullscreen></iframe>', 'Courteney Cox , Neve Campbell', 2, 'Wes Craven', 'The fourth instalment in the popular Scream film series. Ten years have passed, and Sidney Prescott (Neve Campbell), who has put herself back together thanks in part to her writing, is visited by the Ghostface Killer.', 8, '2011-05-14', '2011-05-31'),
('FD773565-99F6-F8BA-B385-145095A28C1B', 'Certified Copy - Travelling Film Festival', '1304851386413Certified Copy - Travelling Film Festival.jpg', '<iframe width="560" height="349" src="http://www.youtube.com/embed/w4nWgtXB51o" frameborder="0" allowfullscreen></iframe>', 'Juliette Binoche, William Shimell and Jean-Claude CarriËre', 2, 'Abbas Kiarostami', 'A sensation at the 2010 Cannes Film Festival, where Juliette Binoche won the Best Actress award, CERTIFIED COPY is the latest masterpiece from acclaimed filmmaker Abbas Kiarostami (TEN, TASTE OF CHERRY). Academy Award-winner Juliette Binoche stars as an antique dealer,', 1, '2011-05-09', '2012-05-26');
-- --------------------------------------------------------
--
-- Table structure for table `RecommendMovie`
--
DROP TABLE IF EXISTS `RecommendMovie`;
CREATE TABLE IF NOT EXISTS `RecommendMovie` (
`RecommendID` varchar(250) NOT NULL,
`ToUser` varchar(250) NOT NULL,
`FromUser` varchar(250) NOT NULL,
`MovieID` varchar(250) NOT NULL,
`IsReaded` tinyint(1) NOT NULL,
PRIMARY KEY (`RecommendID`),
KEY `ToUser` (`ToUser`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `RecommendMovie`
--
INSERT INTO `RecommendMovie` (`RecommendID`, `ToUser`, `FromUser`, `MovieID`, `IsReaded`) VALUES
('21336964-56F1-7C62-55D9-BEBD7AB68825', '6D83531E-3563-CA8C-EFC3-BF51C20709B1', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '093C0B41-19B8-88D5-5C33-3284A612F469', 1),
('373C644E-47BD-4E7B-5748-C1432E8746DC', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57', '093C0B41-19B8-88D5-5C33-3284A612F469', 1),
('4D4D6E4A-20CC-6402-FBBB-264F3DDB0F60', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57', '2686E2E9-2D76-A24A-F651-09CF9E0A3010', 1),
('4E42720B-CC66-8FD2-1452-F22FC3652181', '2C168FB2-537F-FE63-751E-72E1D9DFB349', '8E976A10-6AA2-7765-9B82-B671018C8C57', '4D45650C-B521-D3B2-856B-D6F22BC5337D', 1);
-- --------------------------------------------------------
--
-- Table structure for table `Role`
--
DROP TABLE IF EXISTS `Role`;
CREATE TABLE IF NOT EXISTS `Role` (
`RoleId` varchar(250) NOT NULL,
`RoleName` varchar(500) NOT NULL,
PRIMARY KEY (`RoleId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Role`
--
INSERT INTO `Role` (`RoleId`, `RoleName`) VALUES
('0', 'Viewer'),
('1', 'Owner');
-- --------------------------------------------------------
--
-- Table structure for table `Showtime`
--
DROP TABLE IF EXISTS `Showtime`;
CREATE TABLE IF NOT EXISTS `Showtime` (
`ShowtimeId` varchar(250) NOT NULL,
`CinemaId` varchar(250) NOT NULL,
`MovieId` varchar(250) NOT NULL,
`Showtime` datetime NOT NULL,
`Price` double NOT NULL,
PRIMARY KEY (`ShowtimeId`),
KEY `CinemaId` (`CinemaId`),
KEY `MovieId` (`MovieId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Showtime`
--
INSERT INTO `Showtime` (`ShowtimeId`, `CinemaId`, `MovieId`, `Showtime`, `Price`) VALUES
('101EBFFC-CA44-30A9-CF9F-C917A95EAEA1', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '4C0AFE64-650C-8131-D9E3-F7298AF358F7', '2011-07-08 13:00:00', 20),
('1DE0E83E-28D2-74FD-851F-862C43BB908A', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '91825483-301C-ABF5-8B60-8803CA37B30E', '2011-07-08 13:00:00', 20),
('2DCA4F96-FB49-FDB3-E298-1A1A38F72C8C', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '4D45650C-B521-D3B2-856B-D6F22BC5337D', '2011-07-08 13:00:00', 20),
('2E2A9943-D0CF-FCF8-6471-28EAADB0B4A2', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '2451C98B-8F87-F8D3-7D39-BB220BB42D7B', '2011-07-08 13:00:00', 20),
('2EC87278-E749-E87E-2317-24B323D7545D', '38F25AC6-CFC8-BF3B-70F9-E9372F2693D4', '6DD8C5EF-8E78-917C-A39F-67564C9F8005', '2011-05-12 10:00:00', 20),
('3041E275-757A-F107-49B7-368C41527A32', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '093C0B41-19B8-88D5-5C33-3284A612F469', '2011-06-02 17:00:00', 20),
('35B5F003-545F-56DB-B8B1-52AF3F05E1DB', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', 'A369A889-E233-9D35-62C2-F7E365A6E268', '2011-10-10 13:21:00', 20),
('3BC45477-9A85-AEC6-82FA-5AD95307072B', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '3D41CC2C-6EB2-C95F-410C-899DA86A2371', '2011-07-08 13:00:00', 20),
('3DE2997F-E080-CF6C-D60B-B170018F6DC9', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', 'A369A889-E233-9D35-62C2-F7E365A6E268', '2012-09-10 13:10:00', 20),
('4189D11A-0D07-93B8-CF09-8C6DAF18D185', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', '41D40658-3EA0-C37E-30A4-6E8A351D26E5', '2011-05-31 09:10:00', 56),
('5420A3A1-F330-F9EA-744F-04CC8C2C2185', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '3CA85282-488C-288B-2C35-A668C33C3E64', '2011-07-08 13:00:00', 20),
('6227E7D6-937F-7ED7-781A-06811F0D47A2', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '2686E2E9-2D76-A24A-F651-09CF9E0A3010', '2011-07-08 13:00:00', 20),
('66C54168-3D15-96DA-F03C-78B3137AFD70', '38F25AC6-CFC8-BF3B-70F9-E9372F2693D4', '2686E2E9-2D76-A24A-F651-09CF9E0A3010', '2011-06-05 13:00:00', 30),
('6B5F8848-56C5-EBE9-9C7B-267FF6A8A03E', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '829347A6-2188-A9DD-02AC-40C825FB53F2', '2011-07-08 13:00:00', 20),
('7C06C342-6F10-6E9A-1F61-ECD29B33CF8C', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '7485CE5F-3E06-5FD7-4573-CAD26977A23B', '2011-07-08 13:00:00', 20),
('7EBC2C48-C4B4-A342-27F8-AE5A53561417', '38F25AC6-CFC8-BF3B-70F9-E9372F2693D4', '4D45650C-B521-D3B2-856B-D6F22BC5337D', '2011-06-05 13:00:00', 30),
('933480AB-0147-EDBF-10D4-C95045DBFF87', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '821F85C4-9AD3-5E25-04CB-88EA45FEAD95', '2011-07-08 13:00:00', 20),
('946788FA-FEC3-D748-4889-1B11A77D6C1A', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', '987873AD-0EE2-D42F-906E-4227646BB23C', '2011-10-10 13:21:00', 20),
('9E427918-763D-EE6D-24C7-0C3F46BCFE64', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '093C0B41-19B8-88D5-5C33-3284A612F469', '2011-07-08 13:00:00', 20),
('B0AC002C-9B9B-681D-E73F-62740C2B2A86', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', '6DD8C5EF-8E78-917C-A39F-67564C9F8005', '2011-05-12 10:00:00', 20),
('B7BE6449-A545-2F5A-A43F-D7EED08F8C96', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '6DD8C5EF-8E78-917C-A39F-67564C9F8005', '2011-05-12 10:00:00', 20),
('C6D67EC9-9BC6-7F03-C9C2-08582C73C663', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'EBB9938D-96ED-C90B-737C-D09FD1D692A4', '2011-07-08 13:00:00', 20),
('CFE5E6E3-EA5B-169E-67EA-922BDCCFDC40', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'BDF28154-D726-96D4-80DC-DB9C7B91F07F', '2011-07-08 13:00:00', 20),
('D4F9ED29-8D45-3D98-D7AF-D5301FD90044', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'D06EADEE-F8C7-1D86-A417-5C4B9C7A654C', '2011-07-08 13:00:00', 20),
('DE20A511-8913-6903-4544-C6AC8444B89E', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'C5E236DC-E239-74FE-FCE6-A65F644AF958', '2011-07-08 13:00:00', 20),
('ED754389-A8DC-C035-6CCB-D53650E69E0E', '68D73B31-1EF5-E65B-0CA0-D53498F462E6', '987873AD-0EE2-D42F-906E-4227646BB23C', '2012-09-10 13:10:00', 20),
('F32B3D71-94B2-3EDF-3242-ABB6CC8BE5CC', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', '41D40658-3EA0-C37E-30A4-6E8A351D26E5', '2011-07-08 13:00:00', 20),
('FA0FE1BC-A9A7-D684-CED6-1A0D69674C83', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'B5B72909-23A5-E299-62A5-EC770DDB6444', '2011-07-08 13:00:00', 20),
('FF8A36A4-99DE-4D3C-F82B-E9FCF15B4155', 'EA226BEB-B3D9-A591-CD60-7E1A4A387ABF', 'CEDE9613-B308-27BD-870D-5B9726CD25CE', '2011-07-08 13:00:00', 20);
-- --------------------------------------------------------
--
-- Table structure for table `User`
--
DROP TABLE IF EXISTS `User`;
CREATE TABLE IF NOT EXISTS `User` (
`UserId` varchar(250) NOT NULL,
`UserName` varchar(500) NOT NULL,
`Password` varchar(500) NOT NULL,
`EmailAddress` varchar(500) NOT NULL,
`NickName` varchar(500) DEFAULT NULL,
`FirstName` varchar(500) DEFAULT NULL,
`IsFirstNamePublic` tinyint(1) NOT NULL DEFAULT '0',
`LastName` varchar(500) DEFAULT NULL,
`IsLastNamePublic` tinyint(1) NOT NULL DEFAULT '0',
`YearOfBirth` varchar(500) DEFAULT NULL,
`IsYearOfBirthPublic` tinyint(1) NOT NULL DEFAULT '0',
`FavGenre` int(32) DEFAULT NULL,
`IsFavGenrePublic` tinyint(1) NOT NULL DEFAULT '0',
`FavActors` varchar(500) DEFAULT NULL,
`IsFavActorsPublic` tinyint(1) NOT NULL DEFAULT '0',
`RoleId` varchar(250) DEFAULT '0',
`isVaildate` tinyint(1) NOT NULL DEFAULT '0',
`IsCompletePrivate` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`UserId`),
UNIQUE KEY `UserName` (`UserName`),
UNIQUE KEY `EmailAddress` (`EmailAddress`),
KEY `RoleId` (`RoleId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `User`
--
INSERT INTO `User` (`UserId`, `UserName`, `Password`, `EmailAddress`, `NickName`, `FirstName`, `IsFirstNamePublic`, `LastName`, `IsLastNamePublic`, `YearOfBirth`, `IsYearOfBirthPublic`, `FavGenre`, `IsFavGenrePublic`, `FavActors`, `IsFavActorsPublic`, `RoleId`, `isVaildate`, `IsCompletePrivate`) VALUES
('2C168FB2-537F-FE63-751E-72E1D9DFB349', 'steven', 'b3cd915d758008bd19d0f2428fbb354a', '[email protected]', 'steve', 'steven', 1, 'you', 1, '1988', 1, 8, 1, 'tom', 1, '0', 1, 0),
('5626546A-4F20-448E-6015-F6490B6A547A', 'zz', '25ed1bcb423b0b7200f485fc5ff71c8e', '[email protected]', '', '', 0, '', 0, '', 0, NULL, 0, '', 0, NULL, 0, 0),
('615468FB-45B5-9350-8BD3-C75B7AF2BDA3', 'mmen387', '1d788473204d1a53d260a1af81ab12de', '[email protected]', 'mm', 'meng', 0, 'meng', 0, '1989', 0, 4, 0, 'Justin Bieber', 0, '0', 1, 0),
('6382857C-0933-67E7-A13E-9278EBFC911C', 'aa', '4124bc0a9335c27f086f24ba207a4912', '[email protected]', '', '', 0, '', 0, '', 0, NULL, 0, '', 0, NULL, 0, 0),
('6D83531E-3563-CA8C-EFC3-BF51C20709B1', 'bar', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 'ar', 'bar', 0, 'foo', 0, '1988', 0, 8, 0, '123', 0, '0', 1, 0),
('8E976A10-6AA2-7765-9B82-B671018C8C57', 'foo', 'b3cd915d758008bd19d0f2428fbb354a', '[email protected]', 'foo', 'foo', 1, 'you', 1, '1988', 0, 0, 1, 'looo', 1, '0', 1, 0),
('B85AD097-6437-4D70-E825-F3774896DAB2', 'admin', 'b3cd915d758008bd19d0f2428fbb354a', '[email protected]', '', '', 0, '', 0, '', 0, NULL, 0, '', 0, '1', 1, 0);
| true
|
0185ee888168c83e349f8cd95e7828ce588208cb
|
SQL
|
Velocity-Engineering/airbyte
|
/airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output/postgres/test_primary_key_streams/final/airbyte_tables/test_normalization/nested_stream_with_c__lting_into_long_names.sql
|
UTF-8
| 533
| 2.625
| 3
|
[
"MIT",
"Elastic-2.0"
] |
permissive
|
create table "postgres".test_normalization."nested_stream_with_c__lting_into_long_names__dbt_tmp"
as (
-- Final base SQL model
select
"id",
"date",
"partition",
_airbyte_emitted_at,
_airbyte_nested_stre__nto_long_names_hashid
from "postgres".test_normalization."nested_stream_with_c__lting_into_long_names_scd"
-- nested_stream_with_c__lting_into_long_names from "postgres".test_normalization._airbyte_raw_nested_stream_with_complex_columns_resulting_into_long_names
where _airbyte_active_row = 1
);
| true
|
748ea2f4ab15d600fc4132fd89ecc78cb3cc00ec
|
SQL
|
Salekchowdhury/Toll-Tax-Management
|
/online toll tax management/Database/online_toll_tax_management.sql
|
UTF-8
| 7,909
| 3.03125
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 29, 2021 at 11:06 PM
-- Server version: 10.4.20-MariaDB
-- PHP Version: 7.3.29
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `online_toll_tax_management`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`admin_id` int(11) NOT NULL,
`name` text DEFAULT NULL,
`email` text DEFAULT NULL,
`password` text DEFAULT NULL,
`image` text DEFAULT NULL,
`emailtoken` text DEFAULT NULL,
`phone` text DEFAULT NULL,
`address` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`admin_id`, `name`, `email`, `password`, `image`, `emailtoken`, `phone`, `address`) VALUES
(2, 'md. parvez', '[email protected]', '123456', '../../contents/img/4674toll.jpg', NULL, '01874526322', 'Hathazari,ctg');
-- --------------------------------------------------------
--
-- Table structure for table `notice`
--
CREATE TABLE `notice` (
`id` int(11) NOT NULL,
`notice` text NOT NULL,
`time` time NOT NULL,
`date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `notice`
--
INSERT INTO `notice` (`id`, `notice`, `time`, `date`) VALUES
(1, 'The passage experienced a surge in popularity during the 1960s when Letraset used it on their dry-transfer sheets,The passage experienced a surge in popularity during the 1960s when Letraset used it on their dry-transfer sheets,The passage experienced a surge in popularity during the 1960s when Letraset used it on their dry-transfer sheets,', '13:20:01', '2021-08-21'),
(2, 'The passage experienced a surge in popularity during the 1960s ', '23:28:25', '2021-08-21');
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
CREATE TABLE `payment` (
`payment_id` int(11) NOT NULL,
`user_id` int(11) DEFAULT NULL,
`name` text DEFAULT NULL,
`amount` int(11) DEFAULT NULL,
`phone` text DEFAULT NULL,
`transaction_id` text DEFAULT NULL,
`vehicle_type` text DEFAULT NULL,
`vehicle_no` text DEFAULT NULL,
`date` date DEFAULT NULL,
`status` text DEFAULT 'unseen',
`token` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `payment`
--
INSERT INTO `payment` (`payment_id`, `user_id`, `name`, `amount`, `phone`, `transaction_id`, `vehicle_type`, `vehicle_no`, `date`, `status`, `token`) VALUES
(1, 2, 'Shahriar Parvez', 130, ' 01874524178', 'trty76yuiu', 'Bus', 'T-2172TS', '2021-08-28', 'seen', NULL),
(2, 2, 'Shahriar Parvez', 140, '01841203698', '46rt6y7u', 'Cargo Van', 'S-7uy8236', '2021-08-28', 'seen', 136051);
-- --------------------------------------------------------
--
-- Table structure for table `toll`
--
CREATE TABLE `toll` (
`toll_id` int(11) NOT NULL,
`driver_name` text DEFAULT NULL,
`amount` text DEFAULT NULL,
`vehicle_type` text DEFAULT NULL,
`phone` text DEFAULT NULL,
`vehicle_no` text DEFAULT NULL,
`token` text DEFAULT NULL,
`date` date DEFAULT NULL,
`status` text NOT NULL DEFAULT 'no',
`checkprint` text NOT NULL DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `toll`
--
INSERT INTO `toll` (`toll_id`, `driver_name`, `amount`, `vehicle_type`, `phone`, `vehicle_no`, `token`, `date`, `status`, `checkprint`) VALUES
(6, 'amir', '60', 'Bus', '01874526374', 'T-859674', '185339', '2021-08-23', 'no', 'no'),
(7, 'amir', '60', 'CNG', '01874526321', 'T-859674', '495027', '2021-08-23', 'yes', 'no'),
(8, 'parvez', '130', 'Microbus', '01874526321', 'S-8596123', '927792', '2021-08-23', 'yes', 'no'),
(39, 'MD Imran Hasan', '130', 'Pick Up', '01874859623', 'S-8596148', '387103', '2021-08-25', 'no', 'no'),
(42, 'MD Imran Hasan', 'Advance', 'Cargo Van', '01874526374', 'T-859674', '740552', '2021-08-26', 'yes', 'no'),
(47, 'Shahriar Parvez', '140', 'Cargo Van', '01841203698', 'S-7uy8236', '136051', '2021-08-28', 'no', 'yes');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`name` text DEFAULT NULL,
`email` text DEFAULT NULL,
`password` text DEFAULT NULL,
`position` text DEFAULT NULL,
`image` text DEFAULT NULL,
`address` text DEFAULT NULL,
`bio` text DEFAULT NULL,
`emailtoken` text DEFAULT NULL,
`phone` text DEFAULT NULL,
`payment` text DEFAULT NULL,
`date` date DEFAULT NULL,
`status` text DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`user_id`, `name`, `email`, `password`, `position`, `image`, `address`, `bio`, `emailtoken`, `phone`, `payment`, `date`, `status`) VALUES
(2, 'Shahriar Parvez', '[email protected]', '12345678', 'owner', '../../contents/img/9557m1.jpg', 'Bahddar Hat,ctg', 'Cicero are also reproduced in their exact original form', 'yes', '01817451896', 'yes', NULL, 'yes'),
(3, 'Md. parvez', '[email protected]', '12345', 'staff', '../../contents/img/4276toll2.png', 'Hathazari,ctg', 'Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham', NULL, '01874526321', NULL, NULL, 'no');
-- --------------------------------------------------------
--
-- Table structure for table `vehicle`
--
CREATE TABLE `vehicle` (
`id` int(11) NOT NULL,
`vehicle_no` text DEFAULT NULL,
`vehicle_type` text DEFAULT NULL,
`driver_name` text DEFAULT NULL,
`owner_name` text DEFAULT NULL,
`phone` text DEFAULT NULL,
`date` date DEFAULT NULL,
`status` text NOT NULL DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `vehicle`
--
INSERT INTO `vehicle` (`id`, `vehicle_no`, `vehicle_type`, `driver_name`, `owner_name`, `phone`, `date`, `status`) VALUES
(1, 'T-859674', 'Cargo Van', 'MD Imran Hasan', 'MD Amir Hossain', '01874526374', '2021-08-25', 'no'),
(4, 'S-8596123', 'Bus', 'parvez', 'MD Amir chy', '01874526321', '2021-08-25', 'no');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`admin_id`);
--
-- Indexes for table `notice`
--
ALTER TABLE `notice`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `payment`
--
ALTER TABLE `payment`
ADD PRIMARY KEY (`payment_id`);
--
-- Indexes for table `toll`
--
ALTER TABLE `toll`
ADD PRIMARY KEY (`toll_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`);
--
-- Indexes for table `vehicle`
--
ALTER TABLE `vehicle`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `notice`
--
ALTER TABLE `notice`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `payment`
--
ALTER TABLE `payment`
MODIFY `payment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `toll`
--
ALTER TABLE `toll`
MODIFY `toll_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=49;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `vehicle`
--
ALTER TABLE `vehicle`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
a3c3715191d533495abe4bc68f28481721bd85a9
|
SQL
|
ooad008/SQL
|
/Script.sql
|
UTF-8
| 1,184
| 3.484375
| 3
|
[] |
no_license
|
create database AmazonDB;
create table UserProfile(`name` varchar(50) not null,countrycode varchar(4),mobileno varchar(10),
email varchar(50),`password` varchar(50) not null,profilepic varchar(200),primary key(email));
create table UserAddress(email varchar(50),addressline1 varchar(100),addressline2 varchar(100),city varchar(50),state varchar(50),postalcode varchar(6),
foreign key(email) references UserProfile(email) on delete cascade);
create table Items(itemid bigint,category varchar(50),subcategory varchar(50),subsubcategory varchar(50),
title varchar(50),brand varchar(50),price decimal(10,2) not null,description varchar(200),color varchar(20),
weight decimal(4,2),quantity int ,discount decimal(3,2),primary key(itemid));
create table ItemAttributes(itemid bigint,attribute varchar(50),`value` varchar(50),
foreign key(itemid) references Items(itemid) on delete cascade);
create table Seller(mobileno varchar(10) not null,email varchar(50),itemid bigint,addressline1 varchar(100),
addressline2 varchar(100),city varchar(50),state varchar(50),postalcode varchar(6),
primary key(email),foreign key(itemid) references Items(itemid) on delete cascade);
| true
|
521f3ea7a1e6ae43786a28c4611f9f06f6b4f247
|
SQL
|
guillermocastro/DBM-DB
|
/dbmdb/dbm/Tables/TableUsage.sql
|
UTF-8
| 574
| 3.078125
| 3
|
[
"MIT"
] |
permissive
|
CREATE TABLE [dbm].[TableUsage]
(
[Id] INT NOT NULL IDENTITY(1,1),
CONSTRAINT [PK.TableUsage.Id] PRIMARY KEY CLUSTERED ([Id]),
[InstanceId] NVARCHAR(128) NOT NULL,
CONSTRAINT [FK.TableUsage.InstanceId] FOREIGN KEY ([InstanceId]) REFERENCES [dbm].[Instance] ([InstanceId]) ON DELETE CASCADE ON UPDATE CASCADE,
[DBName] NVARCHAR(128) NOT NULL,
[TableName] NVARCHAR(128) NOT NULL,
[Rows] BIGINT NOT NULL,
[UsedMB] DECIMAL (38,0) NOT NULL,
[UnusedMB] DECIMAL (38,0) NOT NULL,
[SizeMB] DECIMAL (38,0) NOT NULL,
[DataImportUTC] DATETIME NULL DEFAULT GETUTCDATE(),
)
| true
|
eb68a628cdb494ec32edba5bd366dd9ad941bd8d
|
SQL
|
jarivera94/spring
|
/bancol_avaluos/scripts/1.3.8.2/001-ALTER TABLE formato_informe_hipotecario ADD COLUMN.sql
|
UTF-8
| 677
| 2.734375
| 3
|
[] |
no_license
|
ALTER TABLE avaluos.formato_informe_hipotecario ADD COLUMN fecha_remodelacion timestamp with time zone;
COMMENT ON COLUMN avaluos.formato_informe_hipotecario.fecha_remodelacion IS 'Fecha de remodelación';
ALTER TABLE avaluos.formato_informe_hipotecario ADD COLUMN licencia_construccion character varying(255);
COMMENT ON COLUMN avaluos.formato_informe_hipotecario.licencia_construccion IS 'Licencia de Construcción';
ALTER TABLE avaluos.formato_informe_hipotecario ADD COLUMN tipologia_vivienda_unica_familiar character varying(255);
COMMENT ON COLUMN avaluos.formato_informe_hipotecario.tipologia_vivienda_unica_familiar IS 'Tipología de vivienda única familiar';
| true
|
8a1d08df2d4cce726fca15ba4d5f507dca58fb71
|
SQL
|
arachid3/orasash
|
/sash_dev/config.sql
|
UTF-8
| 1,923
| 2.71875
| 3
|
[] |
no_license
|
set linesize 200
set pagesize 999
SET HEAD OFF
SET VER OFF
set feedback off
spool exit.sql
select 'exit' from dual where SYS_CONTEXT ('USERENV', 'SESSION_USER') != upper('SYS');
spool off
@exit.sql
prompt "------------------------------------------------------------------------------------"
prompt Creating repository owner and job kill function using SYS user
prompt "------------------------------------------------------------------------------------"
spool sys_objects.log
@repo_user.sql
@repo_sys_procedure.sql
spool off
WHENEVER SQLERROR CONTINUE NONE
undef ENTER_SASH_TNS
col sash_tns noprint new_value SASH_TNS
accept ENTER_SASH_TNS prompt "Enter TNS alias to connect to database - required for 12c plugable DB [leave it empty to use SID]?"
select case when nvl('&&ENTER_SASH_TNS','x') = 'x' then '' else '@' || nvl('&&ENTER_SASH_TNS','') end sash_tns from dual;
connect &SASH_USER/&SASH_PASS&SASH_TNS
set term off
spool exit.sql
select 'exit' from dual where SYS_CONTEXT ('USERENV', 'SESSION_USER') != upper('&SASH_USER');
spool off
@exit.sql
set term on
prompt "------------------------------------------------------------------------------------"
prompt Installing SASH objects into &SASH_USER schema
prompt "------------------------------------------------------------------------------------"
set term off
@repo_helpers.sql
@repo_schema.sql
@repo_triggers.sql
@repo_views.sql
@sash_repo.sql
@sash_pkg.sql
@sash_xplan.sql
@sash_awr_views.sql
set term on
prompt "------------------------------------------------------------------------------------"
prompt Instalation completed. Starting SASH configuration process
prompt Press Control-C if you do not want to configure target database at that time.
prompt "------------------------------------------------------------------------------------"
@adddb.sql
exit
| true
|
b226db74294a7216f7289c0f6c088018fc1e1ab5
|
SQL
|
evrimulgen/FCR
|
/T_PERSON_ADDR_CONSTRAINT.sql
|
UTF-8
| 667
| 3.140625
| 3
|
[] |
no_license
|
--------------------------------------------------------
-- Constraints for Table T#PERSON_ADDR
--------------------------------------------------------
ALTER TABLE "FCR"."T#PERSON_ADDR" ADD CONSTRAINT "CP#PERSON_ADDR" PRIMARY KEY ("C#PERSON_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TS#DATA1" ENABLE;
ALTER TABLE "FCR"."T#PERSON_ADDR" ADD CONSTRAINT "CC#PERSON_ADDR#PC" CHECK (regexp_like(C#POST_CODE,'^[0-9]{6}$')) ENABLE;
| true
|
4967b8c176cdd245bd43d49f05c39c4e70d62120
|
SQL
|
pazazz/doctor
|
/doctor.sql
|
UTF-8
| 3,575
| 3.59375
| 4
|
[] |
no_license
|
-- 用户信息
create table user
(
user_tel int pk, /* 用户的手机号 */
user_password text, /* 用户密码 */
user_type int /* 用户类型, 医生/患者/其它 */
)
;
-- 患者信息
create table patient_info
(
patient_id int pk,
patient_tel int,
patient_name text,
patient_birth_year int,
patient_medical_history text,
allergy text,
patient_address text,
patient_pay_info text,
patient_score int,
patient_consume_limit int,
patient_insurance_info int,
FOREIGN KEY (patient_tel) REFERENCES user(user_tel)
)
;
-- 医生信息
create table doctor_info
{
doctor_id int pk, /* 医生编号 */
doctor_name text, /* 医生姓名 */
doctor_password text, /* 登录密码 */
doctor_birth_year int, /* 出生年份 */
doctor_tel int, /* 医生电话 */
doctor_mail text, /* 医生邮箱 */
hospital_id id, /* 医生所在医院 */
doctor_dep text, /* 医生科室 */
doctor_level text, /* 医生职称 */
doctor_license int, /* 医师编号 */
docotr_photo blob /* 医师相片 */
docotr_
FOREIGN KEY (patient_tel) REFERENCES user(uer_tel)
FOREIGN KEY (hospital_id) REFERENCES hospital_info(hospital_id)
}
;
-- 医院信息
create table hospital_info
{
hospital_id int pk, /* 医院编号 */
hospital_name text, /* 医院名称 */
hospital_eng_name text, /* 医院英文名 */
hospital_insurance int, /* 医保信息 */
hospital_level text, /* 医院级别 */
hospital_city text, /* 医院所在城市 */
hospital_address text, /* 医院详细地址 */
hospital_tel int, /* 医院电话 */
hospital_license text /* 医院定点医疗机构编码 */
}
;
-- 邀约表
create table invitation_order_info
{
order_id int pk, /* 邀约编号 */
doctor_id int, /* 医生编号 */
patient_ids set, /* 邀约的患者编号,多个,使用集合类型保存 */
order_deploy_time timestamp, /* 发布时间 */
order_implement_time timestamp, /* 邀约诊疗时间,用于计算时间 */
order_address text, /* 诊疗地址 */
order_patients_num int, /* 邀约人数 */
order_real_pat_num int, /* 实际诊疗人数 */
order_price int, /* 邀约价格 */
order_status int, /* 邀约状态: 四种状态 */
order_disease_desc text, /* 备注信息: 可选病症,医生科室信息 */
FOREIGN KEY (doctor_id) REFERENCES doctor_info(doctor_id)
}
-- 处方表
create table prescription_info
{
prescription_id int, /* 处方编号 */
invitation_id int, /* 邀约编号 */
doctor_id int, /* 医生编号 */
patient_id int, /* 患者编号 */
patient_gender int, /* 患者性别 */
patient_age int, /* 患者年龄 */
disease_desc text, /* 病症描述 */
diagnosis_result text, /* 诊断结果 */
disease_catalog text, /* 诊断结果病症的类别 */
prescription_detail text /* 处方内容, 字符串保存的类 json 格式 */
prescription_doctor_eval text, /* 医生对病人的评价 */
prescription_patient_eval text /* 病人对医生的评价 */
FOREIGN KEY (doctor_id) REFERENCES doctor_info(doctor_id),
FOREIGN KEY (patient_id) REFERENCES patient_info(patient_id)
FOREIGN KEY (invitation_id) REFERENCES invitation_order_info(order_id)
}
;
-- 药品信息
create table medicine_info
{
medicine_id int pk, /* 药品名 */
medicine_custom_name text, /* 常用名 */
medicine_standard_name text, /* 学名 */
medicine_eng_name text, /* 英文名 */
medicine_insurance_type int /* 药品的医保类型 */
}
;
| true
|
a0e9485d45b521ad7fb6bd85896eb8da4e423ac4
|
SQL
|
Amreshhub/SQL
|
/SUBQUERY/moviess.sql
|
UTF-8
| 191
| 2.53125
| 3
|
[] |
no_license
|
create table moviess
(mid varchar2(10) constraint mm_ip_kk primary key,movie_name varchar2(30) not null,category varchar2(20) not null,
cost number(12,2) not null,relesd_date date not null)
/
| true
|
62f7ab94a97ed0cf34dbd3a1f2e79444beb9b773
|
SQL
|
Krismix1/db_mandatory_1
|
/task2/triggers_subroutines.sql
|
UTF-8
| 4,173
| 4.5
| 4
|
[] |
no_license
|
USE library;
-- -------------------------------------------------- --
-- Check if there is a book copy available for a name --
-- -------------------------------------------------- --
DROP FUNCTION IF EXISTS `book_copy_available`;
DELIMITER $
CREATE FUNCTION `book_copy_available`(title varchar(64))
RETURNS tinyint(1) DETERMINISTIC
RETURN (SELECT EXISTS(SELECT 1 FROM book_copies c -- TODO: Maybe reconsider using `exists` for better performance
INNER JOIN books b ON b.id = c.book_id
WHERE b.title = title AND c.status = 'available'));$
DELIMITER ;
-- ----------------------------------- --
-- Find all borrowers for a book title --
-- ----------------------------------- --
DROP PROCEDURE IF EXISTS `find_all_borrowers_of_title`;
DELIMITER $
-- Procedure to find any person who had borrowed or has an ongoing loan for a specific title
CREATE PROCEDURE `find_all_borrowers_of_title` (IN title varchar(64))
BEGIN
SELECT br.* FROM borrowers br
INNER JOIN loans l ON l.borrower_id = br.id
INNER JOIN book_copies c ON c.copy_number = l.book_copy_number
INNER JOIN books b ON b.id = c.book_id
WHERE b.title = title;
END$
DELIMITER ;
-- ------------------------------------------- --
-- Find all current borrowers for a book title --
-- ------------------------------------------- --
DROP PROCEDURE IF EXISTS `find_current_borrowers_of_title`;
DELIMITER $
-- Procedure to find any person who had borrowed or has an ongoing loan for a specific title
CREATE PROCEDURE `find_current_borrowers_of_title` (IN title varchar(64))
BEGIN
SELECT br.* FROM borrowers br
INNER JOIN loans l ON l.borrower_id = br.id
INNER JOIN book_copies c ON c.copy_number = l.book_copy_number
INNER JOIN books b ON b.id = c.book_id
WHERE b.title = title AND l.returned_at IS NULL;
END$
DELIMITER ;
-- ----------------------------------------------------- --
-- Constraint on how many books a borrower_type can loan --
-- ----------------------------------------------------- --
DROP PROCEDURE IF EXISTS `check_max_loan`;
DELIMITER $
CREATE PROCEDURE `check_max_loan`(IN borrower_id int unsigned)
BEGIN
DECLARE total_loans tinyint DEFAULT 0;
DECLARE max_loans tinyint DEFAULT 0;
SELECT COUNT(1) INTO total_loans FROM loans l WHERE l.borrower_id = borrower_id;
SELECT t.max_books_count INTO max_loans
FROM borrower_types t INNER JOIN borrowers b ON t.id = b.borrower_type_id
WHERE b.id = borrower_id GROUP BY b.id ORDER BY b.id;
IF total_loans >= max_loans THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'check constraint on borrower_types.max_books_count failed';
END IF;
END$
DELIMITER ;
-- Before insert
DROP TRIGGER IF EXISTS `loans_before_insert`;
DELIMITER $
CREATE TRIGGER `loans_before_insert` BEFORE INSERT ON `loans`
FOR EACH ROW
BEGIN
CALL check_max_loan(new.borrower_id);
END$
DELIMITER ;
-- Before update
DROP TRIGGER IF EXISTS `loans_before_update`;
DELIMITER $
CREATE TRIGGER `loans_before_update` BEFORE UPDATE ON `loans`
FOR EACH ROW
BEGIN
CALL check_max_loan(new.borrower_id);
END$
DELIMITER ;
-- ------------------------------------------- --
-- Find all borrowers that had an overdue ever --
-- ------------------------------------------- --
DROP PROCEDURE IF EXISTS `find_all_borrowers_with_overdue`;
DELIMITER $
CREATE PROCEDURE `find_all_borrowers_with_overdue`()
BEGIN
SELECT DISTINCT br.* FROM borrowers br
INNER JOIN loans l ON l.borrower_id = br.id
WHERE (l.returned_at IS NULL AND DATEDIFF(NOW(), l.loaned_at) > l.loan_period)
OR (l.returned_at IS NOT NULL AND DATEDIFF(l.returned_at, l.loaned_at) > l.loan_period);
END$
DELIMITER ;
-- ------------------------------------------ --
-- Find current borrowers that had an overdue --
-- ------------------------------------------ --
DROP PROCEDURE IF EXISTS `find_all_current_borrowers_with_overdue`;
DELIMITER $
CREATE PROCEDURE `find_all_current_borrowers_with_overdue`()
BEGIN
SELECT DISTINCT br.* FROM borrowers br
INNER JOIN loans l ON l.borrower_id = br.id
WHERE DATEDIFF(NOW(), l.loaned_at) > l.loan_period AND l.returned_at IS NULL;
END$
DELIMITER ;
| true
|
500eb7db1c5e947a27754e69ed948019ad5e708f
|
SQL
|
JonathanCh022/pedidos
|
/basepedidos (3).sql
|
UTF-8
| 7,993
| 3.171875
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 24-07-2016 a las 23:27:53
-- Versión del servidor: 5.6.17
-- Versión de PHP: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de datos: `basepedidos`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `clientes`
--
CREATE TABLE IF NOT EXISTS `clientes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cli_cedula` varchar(15) NOT NULL,
`ven_codigo` varchar(5) NOT NULL,
`cli_nombre` varchar(60) NOT NULL,
`cli_negocio` varchar(60) NOT NULL,
`cli_direccion` varchar(60) NOT NULL,
`cli_email` varchar(60) NOT NULL,
`cli_telefono` varchar(60) NOT NULL,
`cli_latitud` float NOT NULL,
`cli_longitud` float NOT NULL,
PRIMARY KEY (`id`),
KEY `ven_codigo` (`ven_codigo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
--
-- Volcado de datos para la tabla `clientes`
--
INSERT INTO `clientes` (`id`, `cli_cedula`, `ven_codigo`, `cli_nombre`, `cli_negocio`, `cli_direccion`, `cli_email`, `cli_telefono`, `cli_latitud`, `cli_longitud`) VALUES
(1, '1098744', '1', 'carlos vega', 'bodytech', 'calle 213', '[email protected]', '6785494', 0, 0),
(2, '1098456', '1', 'cindy acosta', 'éxito', 'carrera 123', '[email protected]', '6785687', 0, 0),
(3, '1097586', '1', 'camilo soto', 'jumbo', 'diagonal 123', '[email protected]', '6764564', 0, 0),
(4, '1098632', '2', 'tony duran', 'cadena1', 'transversal 123', '[email protected]', '6458564', 0, 0),
(5, '1098642', '2', 'diana arevalo', 'ecopetrol', 'calle 563', '[email protected]', '6896552', 0, 0),
(6, '1098562', '3', 'carolina diaz', 'cardio1', 'carrera 568', '[email protected]', '6789541', 0, 0),
(7, '1098741', '4', 'marcela rojas', 'tienda34', 'calle 896', '[email protected]', '6895412', 0, 0);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `empresa`
--
CREATE TABLE IF NOT EXISTS `empresa` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`emp_nit` varchar(15) NOT NULL,
`emp_raz_soc` varchar(120) NOT NULL,
`emp_email` varchar(60) NOT NULL,
`emp_telefono` varchar(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Volcado de datos para la tabla `empresa`
--
INSERT INTO `empresa` (`id`, `emp_nit`, `emp_raz_soc`, `emp_email`, `emp_telefono`) VALUES
(1, '102458', 'Buscamos enriquecernos de forma rapida y segura.', '[email protected]', '6785941');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `inventario`
--
CREATE TABLE IF NOT EXISTS `inventario` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`inv_referencia` varchar(20) NOT NULL,
`inv_descripcion` varchar(100) NOT NULL,
`inv_porc_iva` int(2) NOT NULL,
`inv_precio_vta` float NOT NULL,
`inv_existencias` float NOT NULL,
`inv_pedidas` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Volcado de datos para la tabla `inventario`
--
INSERT INTO `inventario` (`id`, `inv_referencia`, `inv_descripcion`, `inv_porc_iva`, `inv_precio_vta`, `inv_existencias`, `inv_pedidas`) VALUES
(1, 'rt7854', 'colcafe ', 2, 7000, 300, 0),
(2, 'rt8965', 'cerveza aguila', 2, 9000, 1000, 0),
(3, 'rt3624', 'galletas ducales', 4, 10000, 5000, 0),
(4, 'rt8745', 'mayonesa fruco', 5, 25000, 10000, 0);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `pedido_articulos`
--
CREATE TABLE IF NOT EXISTS `pedido_articulos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pda_numero` int(10) NOT NULL,
`pda_referencia` varchar(20) NOT NULL,
`pda_descuento` float NOT NULL,
`pda_cantidad_ped` float NOT NULL,
`pda_cantidad_apro` float NOT NULL,
`pda_cantidad_factu` float NOT NULL,
`pda_estado` varchar(2) NOT NULL,
PRIMARY KEY (`id`),
KEY `pda_numero` (`pda_numero`),
KEY `pda_referencia` (`pda_referencia`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Volcado de datos para la tabla `pedido_articulos`
--
INSERT INTO `pedido_articulos` (`id`, `pda_numero`, `pda_referencia`, `pda_descuento`, `pda_cantidad_ped`, `pda_cantidad_apro`, `pda_cantidad_factu`, `pda_estado`) VALUES
(1, 1, 'huevos', 2, 10, 8, 10, '0'),
(2, 1, 'leche', 1, 10, 5, 10, '1'),
(3, 2, 'huevos', 0, 5, 5, 5, '1'),
(4, 3, 'leche', 2, 15, 15, 15, '1');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `pedido_general`
--
CREATE TABLE IF NOT EXISTS `pedido_general` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pdg_numero` int(10) NOT NULL,
`pdg_fecha` date NOT NULL,
`pdg_cliente` varchar(15) NOT NULL,
`pdg_estado` varchar(2) NOT NULL,
`pdg_vendedor` varchar(5) NOT NULL,
`pdg_hora` time NOT NULL,
`pdg_latitud` float NOT NULL,
`pdg_longitud` float NOT NULL,
PRIMARY KEY (`id`),
KEY `pdg_vendedor` (`pdg_vendedor`),
KEY `pdg_cliente` (`pdg_cliente`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Volcado de datos para la tabla `pedido_general`
--
INSERT INTO `pedido_general` (`id`, `pdg_numero`, `pdg_fecha`, `pdg_cliente`, `pdg_estado`, `pdg_vendedor`, `pdg_hora`, `pdg_latitud`, `pdg_longitud`) VALUES
(1, 1, '2016-07-04', '1', '3', '1', '03:00:00', 2, 2),
(2, 2, '2016-07-05', '2', '1', '1', '00:19:00', 2, 2),
(3, 3, '2016-07-11', '3', '1', '2', '05:00:00', 2, 2);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `rutero`
--
CREATE TABLE IF NOT EXISTS `rutero` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rut_vendedor` varchar(5) NOT NULL,
`rut_dia` varchar(2) NOT NULL,
`rut_cliente` varchar(15) NOT NULL,
`rut_orden` varchar(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
--
-- Volcado de datos para la tabla `rutero`
--
INSERT INTO `rutero` (`id`, `rut_vendedor`, `rut_dia`, `rut_cliente`, `rut_orden`) VALUES
(1, '1', '8', '1098744', '1'),
(2, '1', '9', '1097586', '2'),
(3, '1', '12', '1098456', '3'),
(4, '2', '15', '1098632', '4'),
(5, '2', '14', '1098642', '5'),
(6, '3', '21', '1098562', '6'),
(7, '4', '29', '1098741', '7');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `usuarios`
--
CREATE TABLE IF NOT EXISTS `usuarios` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`usu_nit` varchar(15) NOT NULL,
`usu_nombre` varchar(60) NOT NULL,
`usu_clave` varchar(15) NOT NULL,
`usu_rol` varchar(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Volcado de datos para la tabla `usuarios`
--
INSERT INTO `usuarios` (`id`, `usu_nit`, `usu_nombre`, `usu_clave`, `usu_rol`) VALUES
(1, '1001', 'javier', '1345', '1');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `vendedores`
--
CREATE TABLE IF NOT EXISTS `vendedores` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ven_codigo` varchar(5) NOT NULL,
`ven_nombre` varchar(40) NOT NULL,
`ven_email` varchar(40) NOT NULL,
`ven_telefono` varchar(15) NOT NULL,
`usu_nit` varchar(15) NOT NULL,
PRIMARY KEY (`id`),
KEY `usu_nit` (`usu_nit`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Volcado de datos para la tabla `vendedores`
--
INSERT INTO `vendedores` (`id`, `ven_codigo`, `ven_nombre`, `ven_email`, `ven_telefono`, `usu_nit`) VALUES
(1, '1', 'alejandro sanchez', '[email protected]', '6785494', '0'),
(2, '2', 'javier sanchez', '[email protected]', '6785687', '0'),
(3, '3', 'alejandro castro', '[email protected]', '6764564', '1001'),
(4, '4', 'carolina suarez', '[email protected]', '6458564', '2');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
bb3f10bd6f8665232f3bead83ef4907fdc70e38a
|
SQL
|
pjuliano/glowing-waffle
|
/Dropped/KD_WWSS Views.sql
|
UTF-8
| 12,459
| 3.65625
| 4
|
[] |
no_license
|
Create or Replace View KD_WWSS_Yesterday As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.AllAmounts) As Yesterday
From
Kd_Sales_Data_Request A
Where
A.Invoicedate = Trunc(Sysdate-1)
Group By
A.Part_Product_Family,
A.Corporate_Form
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create or Replace View KD_WWSS_Today As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As Today
From
Kd_Sales_Data_Request A
Where
A.Invoicedate = Trunc(Sysdate)
Group By
A.Part_Product_Family,
A.Corporate_Form
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create or Replace View KD_WWSS_This_Month As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As This_Month,
Case
When
Extract(Month From Sysdate) = 1
Then
B.Jan
When
Extract(Month From Sysdate) = 2
Then
B.Feb
When
Extract(Month From Sysdate) = 3
Then
B.Mar
When
Extract(Month From Sysdate) = 4
Then
B.Apr
When
Extract(Month From Sysdate) = 5
Then
B.May
When
Extract(Month From Sysdate) = 6
Then
B.Jun
When
Extract(Month From Sysdate) = 7
Then
B.Jul
When
Extract(Month From Sysdate) = 8
Then
B.Aug
When
Extract(Month From Sysdate) = 9
Then
B.Sep
When
Extract(Month From Sysdate) = 10
Then
B.Oct
When
Extract(Month From Sysdate) = 11
Then
B.Nov
When
Extract(Month From Sysdate) = 12
Then
B.Dec
Else
0
End As Month_Quota
From
Kd_Sales_Data_Request A Left Join Srfcstbyfam B
On A.Part_Product_Family = B.Family And
A.Corporate_Form = B.F1
Where
Extract(Month From A.Invoicedate) = Extract(Month From Sysdate) And
Extract(Year From A.InvoiceDate) = Extract(Year From Sysdate)
Group By
A.Part_Product_Family,
A.Corporate_Form,
Case
When
Extract(Month From Sysdate) = 1
Then
B.Jan
When
Extract(Month From Sysdate) = 2
Then
B.Feb
When
Extract(Month From Sysdate) = 3
Then
B.Mar
When
Extract(Month From Sysdate) = 4
Then
B.Apr
When
Extract(Month From Sysdate) = 5
Then
B.May
When
Extract(Month From Sysdate) = 6
Then
B.Jun
When
Extract(Month From Sysdate) = 7
Then
B.Jul
When
Extract(Month From Sysdate) = 8
Then
B.Aug
When
Extract(Month From Sysdate) = 9
Then
B.Sep
When
Extract(Month From Sysdate) = 10
Then
B.Oct
When
Extract(Month From Sysdate) = 11
Then
B.Nov
When
Extract(Month From Sysdate) = 12
Then
B.Dec
Else
0
End
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create Or Replace View KD_WWSS_This_Quarter As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As This_Qtr,
Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
B.Q1
When
Extract(Month From Sysdate) In (4,5,6)
Then
B.Q2
When
Extract(Month From Sysdate) In (7,8,9)
Then
B.Q3
When
Extract(Month From Sysdate) In (10,11,12)
Then
B.Q4
End As QTR_Quota
From
Kd_Sales_Data_Request A Left Join Srfcstbyfam B
On A.Part_Product_Family = B.Family And
A.Corporate_Form = B.F1
Where
A.InvoiceQtr = Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
'QTR1'
When
Extract(Month From Sysdate) In (4,5,6)
Then
'QTR2'
When
Extract(Month From Sysdate) In (7,8,9)
Then
'QTR3'
When
Extract(Month From Sysdate) In (10,11,12)
Then
'QTR4'
End And
Extract(Year From A.InvoiceDate) = Extract(Year From Sysdate)
Group By
A.Part_Product_Family,
A.Corporate_Form,
Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
B.Q1
When
Extract(Month From Sysdate) In (4,5,6)
Then
B.Q2
When
Extract(Month From Sysdate) In (7,8,9)
Then
B.Q3
When
Extract(Month From Sysdate) In (10,11,12)
Then
B.Q4
End
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create Or Replace View KD_WWSS_This_Year As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As This_Year,
B.Total As Total_Quota
From
Kd_Sales_Data_Request A Left Join Srfcstbyfam B
On A.Part_Product_Family = B.Family And
A.Corporate_Form = B.F1
Where
Extract(Year From A.Invoicedate) = Extract(Year From Sysdate)
Group By
A.Part_Product_Family,
A.Corporate_Form,
B.Total
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create Or Replace View KD_WWSS_Last_Quarter As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As Last_Qtr
From
Kd_Sales_Data_Request A
Where
A.InvoiceQtr = Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
'QTR4'
When
Extract(Month From Sysdate) In (4,5,6)
Then
'QTR1'
When
Extract(Month From Sysdate) In (7,8,9)
Then
'QTR2'
When
Extract(Month From Sysdate) In (10,11,12)
Then
'QTR3'
End And
Extract(Year From A.Invoicedate) = Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
Extract(Year From Sysdate) - 1
Else
Extract(Year From Sysdate)
End
Group By
A.Part_Product_Family,
A.Corporate_Form
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create or Replace View KD_WWSS_This_QTR_Last_Year As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As This_Qtr_Last_Year,
B.Total
From
Kd_Sales_Data_Request A Left Join Srfcstbyfam B
On A.Part_Product_Family = B.Family And
A.Corporate_Form = B.F1
Where
Extract(Year From A.Invoicedate) = Extract(Year From Sysdate) - 1 And
A.InvoiceQtr = Case
When
Extract(Month From Sysdate) In (1,2,3)
Then
'QTR1'
When
Extract(Month From Sysdate) In (4,5,6)
Then
'QTR2'
When
Extract(Month From Sysdate) In (7,8,9)
Then
'QTR3'
When
Extract(Month From Sysdate) In (10,11,12)
Then
'QTR4'
End
Group By
A.Part_Product_Family,
A.Corporate_Form,
B.Total
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create or Replace View KD_WWSS_Last_Year As
Select
A.Part_Product_Family,
A.Corporate_Form,
Sum(A.Allamounts) As Last_Year,
B.Total
From
Kd_Sales_Data_Request A Left Join Srfcstbyfam B
On A.Part_Product_Family = B.Family And
A.Corporate_Form = B.F1
Where
Extract(Year From A.Invoicedate) = Extract(Year From Sysdate) - 1 And
--Begin Change 03012017
--Column on Report should be Year to Date not Year Total.
--A.Invoicedate <= Trunc(Sysdate)
A.Invoicedate <= To_Date(To_Char(Extract(Month From Sysdate)) || '/' || To_Char(Extract(Day From Sysdate)) || '/' || To_Char(Extract(Year From Sysdate) - 1),'MM/DD/YYYY')
--End Change 03012017
Group By
A.Part_Product_Family,
A.Corporate_Form,
B.Total
Order By
A.Part_Product_Family,
A.Corporate_Form;
Create Or Replace View KD_WWSS As
Select
A.Part_Product_Family,
A.Corporate_Form,
Case
When
A.Part_Product_Family In ('PRIMA','GNSIS','TRINX','RESTO','EXHEX','ZMAX','OCT','RENOV','STAGE','XP1','COMM','OTMED')
Then
'IMPLANT'
When
A.Part_Product_Family In ('BVINE','CONNX','CYTOP','DYNAB','DYNAG','DYNAC','DYNAM','SYNTH','MTF')
Then
'REGEN'
When
A.Part_Product_Family = 'EG'
Then
'EG'
When
A.Part_Product_Family = 'Freight'
Then
'FREIGHT'
Else
'OTHER'
End As Code,
B.Today,
C.Yesterday,
D.This_Month,
D.Month_Quota,
Case
When
D.Month_Quota Is Not Null And
D.Month_Quota != 0
Then
Round((D.This_Month / D.Month_Quota) * 100,2)
End As Pct_To_Month,
D.Month_Quota - D.This_Month As Left_Month,
Case
When
H.Elapsed_Work_Days != 0
Then
Round(D.This_Month / H.Elapsed_Work_Days,2)
End As Month_Avg_Sales_To_Date,
Case
When
H.Total_Sales_Days - H.Elapsed_Work_Days != 0
Then
Round((D.Month_Quota - D.This_Month) / (H.Total_Sales_Days - H.Elapsed_Work_Days),2)
End As Month_Req_Daily_Sales,
E.This_Qtr,
E.Qtr_Quota,
Case
When
E.Qtr_Quota Is Not Null And
E.Qtr_Quota != 0
Then
Round((E.This_Qtr / E.Qtr_Quota) * 100,2)
End As Pct_To_Qtr,
E.Qtr_Quota - E.This_Qtr As Left_Qtr,
Case
When
I.Elapsed_Work_Days != 0
Then
Round(E.This_Qtr / I.Elapsed_Work_Days,2)
End As Qtr_Avg_Sales_To_Date,
Case
When
I.Total_Sales_Days - I.Elapsed_Work_Days != 0
Then
Round((E.Qtr_Quota - E.This_Qtr) / (I.Total_Sales_Days - I.Elapsed_Work_Days),2)
End As Qtr_Req_Daily_Sales,
Round(Case
When
E.Qtr_Quota Is Not Null And
E.Qtr_Quota != 0
Then
(E.This_Qtr / E.Qtr_Quota) * 100
End /
(I.Elapsed_Work_Days / I.Total_Sales_Days),2) As Qtr_Run_Rate,
A.This_Year,
A.Total_Quota,
Case
When
A.Total_Quota Is Not Null And
A.Total_Quota != 0
Then
Round((A.This_Year / A.Total_Quota) * 100,2)
End As Pct_To_Year,
A.Total_Quota - This_Year As Left_Year,
F.Last_Qtr,
Case
When
F.Last_Qtr Is Not Null And
F.Last_Qtr != 0
Then
Round((E.This_Qtr / F.Last_Qtr) * 100,2)
End As Pct_Last_Qtr,
K.This_Qtr_Last_Year,
Case
When
K.This_Qtr_Last_Year != 0
Then
Round((E.This_Qtr / K.This_Qtr_Last_Year) * 100,2)
End As PCT_This_Qtr_Last_Year,
G.Last_Year As Last_YTD,
Case
When
G.Last_Year Is Not Null And
G.Last_Year != 0
Then
Round((A.This_Year / G.Last_Year) * 100,2)
End As Pct_Last_Ytd,
H.Total_Sales_Days As Work_Days_This_Month,
H.Holidays As Holidays_This_Month,
H.Elapsed_Work_Days As Elapsed_Work_Days_This_Month,
I.Total_Sales_Days As Work_Days_This_Qtr,
I.Holidays As Holidays_This_Qtr,
I.Elapsed_Work_Days As Elapsed_Work_Days_This_Qtr,
J.Total_Sales_Days As Work_Days_This_Year,
J.Holidays As Holidays_This_Year,
J.Elapsed_Work_Days As Elapsed_Work_Days_This_Year
From
Kd_Wwss_This_Year A Left Join Kd_Wwss_Today B
On A.Part_Product_Family = B.Part_Product_Family And
A.Corporate_Form = B.Corporate_Form
Left Join Kd_Wwss_Yesterday C
On A.Part_Product_Family = C.Part_Product_Family And
A.Corporate_Form = C.Corporate_Form
Left Join Kd_Wwss_This_Month D
On A.Part_Product_Family = D.Part_Product_Family And
A.Corporate_Form = D.Corporate_Form
Left Join Kd_Wwss_This_Quarter E
On A.Part_Product_Family = E.Part_Product_Family And
A.Corporate_Form = E.Corporate_Form
Left Join Kd_Wwss_Last_Quarter F
On A.Part_Product_Family = F.Part_Product_Family And
A.Corporate_Form = F.Corporate_Form
Left Join Kd_Wwss_Last_Year G
On A.Part_Product_Family = G.Part_Product_Family And
A.Corporate_Form = G.Corporate_Form
Left Join Kd_Wwss_This_Qtr_Last_Year K
On A.Part_Product_Family = K.Part_Product_Family And
A.Corporate_Form = K.Corporate_Form,
Kd_Work_Days_This_Month H,
Kd_Work_Days_This_Quarter I,
Kd_Work_Days_This_Year J;
| true
|
6c586d8d388807c980099d19c26942e89b44ada6
|
SQL
|
ScribesZone/ModelScript
|
/resources/classroom-root/XXX-CASESTUDY/bd/sql/requetes/Q091_ThePhilsCinemas2.sql
|
UTF-8
| 135
| 3.34375
| 3
|
[
"MIT"
] |
permissive
|
SELECT Cinemas.name, Cinemas.city
FROM Cinemas JOIN Frequents ON (Cinemas.name = Frequents.cinema)
where Frequents.spectator = 'Phil' ;
| true
|
923496e61cb18f5f4767fb5469f61bc82e33071a
|
SQL
|
Jpub/OraclePLSQL
|
/list11-04.sql
|
UTF-8
| 423
| 2.6875
| 3
|
[] |
no_license
|
CREATE OR REPLACE PROCEDURE emp_pro2(
empcur IN cur_pack.emp_type)
IS
emp_var1 emp.empno%TYPE;
emp_var2 emp.ename%TYPE;
emp_var3 emp.sal%TYPE;
BEGIN
LOOP
FETCH empcur INTO emp_var1, emp_var2, emp_var3;
EXIT WHEN empcur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(emp_var1||' '||
emp_var2||' '||
emp_var3);
END LOOP;
END;
/
EXECUTE emp_pro1(10)
| true
|
b8f162a7a0a06a7def72bc113782c9e684acf6ce
|
SQL
|
Sankarb475/Project_On_Spark_Cassanrda_Scala
|
/Desktop/Noah/FindingDataBasedOnCountries/src/main/resources/InputFile/cassandraQueries.cql
|
UTF-8
| 1,069
| 3.28125
| 3
|
[] |
no_license
|
CREATE KEYSPACE IF NOT EXISTS SparkToCassandra WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE SparkToCassandra.AdultDataTable (
age int,
employer text,
salary int,
education text,
educationyear int,
colour text,
country text,
familystatus text,
gender text,
jobdesignation text,
maritalstatus text,
points1 int,
points2 int,
points3 int,
salarytype text,
PRIMARY KEY (age, employer, salary, education, educationyear)
);
CREATE TABLE SparkToCassandra.CountryWiseSalaryTable (
salary int,
country text,
PRIMARY KEY (country)
);
CREATE TABLE SparkToCassandra.CountryWiseBachelorTable (
country text,
counting int,
PRIMARY KEY (country)
);
CREATE TABLE SparkToCassandra.CountryWiseAvgAgeTable (
age int,
country text,
PRIMARY KEY (country)
);
CREATE TABLE SparkToCassandra.DivorceDataTable (
avgage int,
country text,
maritalstatus text,
gender text,
PRIMARY KEY (country)
);
| true
|
ff29675ca385636ccf0dcb334df24bc550c58b23
|
SQL
|
KBNLresearch/Demosaurus
|
/ML_Nizar/experiment2/AT.sql
|
UTF-8
| 2,261
| 3.796875
| 4
|
[
"Apache-2.0"
] |
permissive
|
WITH link AS (
SELECT publication_ppn,
author_NTA.foaf_familyname AS last_name,
authorship_ggc.author_ppn,
"role",
kind,
rank
FROM authorship_ggc
LEFT JOIN author_NTA
on authorship_ggc.author_ppn = author_NTA.author_ppn
WHERE authorship_ggc.kind LIKE 'primair'
),
ppns AS (SELECT DISTINCT author_ppn FROM author_embeddings),
subset_nta AS (
SELECT *
FROM ppns LEFT JOIN author_NTA
ON ppns.author_ppn = author_NTA.author_ppn)
SELECT
publication_basicinfo.publication_ppn,
publication_basicinfo.titelvermelding,
publication_basicinfo.jaar_van_uitgave,
publication_basicinfo.land_van_uitgave,
publication_basicinfo.taal_origineel,
publication_basicinfo.taal_publicatie,
publication_basicinfo.uitgever_agg,
publication_basicinfo.uitgever_2_agg,
publication_basicinfo.number_of_authors,
publication_basicinfo.length_of_titelvermelding,
publication_basicinfo.number_of_words_in_titelvermelding,
ppn_genrelist.genres,
ppn_themalist.themas,
publication_NUR_rubriek.NUR_rubriek,
publication_NUGI_genre.NUGI_genre,
cast(REPLACE(jaar_van_uitgave, 'X', '5') AS integer) - cast(REPLACE(subset_nta.birthyear, 'X', '5') AS integer) AS age_when_published,
subset_nta.editorial,
subset_nta.editorial_nl,
link.last_name, -- used for linking
link.author_ppn = subset_nta.author_ppn AS target, -- training/ test signal
subset_nta.author_ppn, -- ppn only for reference
publication_sets.datasplit
FROM publication_basicinfo
LEFT JOIN link
ON publication_basicinfo.publication_ppn = link.publication_ppn
LEFT JOIN ppn_themalist
ON publication_basicinfo.publication_ppn = ppn_themalist.publication_ppn
LEFT JOIN ppn_genrelist
ON publication_basicinfo.publication_ppn = ppn_genrelist.publication_ppn
LEFT JOIN publication_NUR_rubriek
ON publication_basicinfo.publication_ppn = publication_NUR_rubriek.publication_ppn
LEFT JOIN publication_NUGI_genre
ON publication_basicinfo.publication_ppn = publication_NUGI_genre.publication_ppn
LEFT JOIN publication_sets
ON publication_basicinfo.publication_ppn = publication_sets.publication_ppn
LEFT JOIN subset_nta
ON link.last_name LIKE subset_nta.foaf_familyname
| true
|
157dcfc353b76b92a8994d719712847d88c193ec
|
SQL
|
fashionbrot/mars-example
|
/sql/initSql.sql
|
UTF-8
| 11,799
| 3.65625
| 4
|
[] |
no_license
|
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`user_name` varchar(30) NOT NULL COMMENT '用户名',
`real_name` varchar(20) NOT NULL COMMENT '真实姓名',
`password` varchar(32) NOT NULL COMMENT '加密密码',
`salt` varchar(32) NOT NULL COMMENT '密码加盐参数',
`status` tinyint(2) NOT NULL COMMENT '用户状态',
`super_admin` tinyint(1) DEFAULT '0' COMMENT '是否是超级管理员 1超级 0普通',
`last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
`create_id` bigint(11) NOT NULL COMMENT '创建者id',
`create_date` datetime NOT NULL COMMENT '创建时间',
`update_id` bigint(11) DEFAULT NULL COMMENT '最近更新者id',
`update_date` datetime DEFAULT NULL COMMENT '最近更新时间',
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志位 1删除 0未删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息表';
ALTER TABLE user_info ADD INDEX index_del_flag (del_flag);
DROP TABLE IF EXISTS `role_info`;
CREATE TABLE `role_info` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`role_code` varchar(30) NOT NULL COMMENT '角色标识',
`role_name` varchar(30) NOT NULL COMMENT '角色描述',
`status` int(2) NOT NULL COMMENT '权限状态',
`create_id` bigint(11) NOT NULL COMMENT '创建者id',
`create_date` datetime NOT NULL COMMENT '创建时间',
`update_id` bigint(11) DEFAULT NULL COMMENT '最近更新者id',
`update_date` datetime DEFAULT NULL COMMENT '最近更新时间',
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志位 1删除 0未删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色表';
ALTER TABLE role_info ADD INDEX index_del_flag (del_flag);
DROP TABLE IF EXISTS `user_role_relation`;
CREATE TABLE `user_role_relation` (
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
`create_id` bigint(11) NOT NULL COMMENT '创建者id',
`create_date` datetime NOT NULL COMMENT '创建时间',
`update_id` bigint(11) DEFAULT NULL COMMENT '最近更新者id',
`update_date` datetime DEFAULT NULL COMMENT '最近更新时间',
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志位 1删除 0未删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-角色关系表';
ALTER TABLE user_role_relation ADD INDEX index_del_flag (del_flag);
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu` (
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`menu_name` varchar(16) NOT NULL COMMENT '菜单名称',
`menu_level` int(3) unsigned NOT NULL COMMENT '菜单级别',
`menu_url` varchar(255) DEFAULT NULL COMMENT '菜单url',
`parent_menu_id` bigint(11) unsigned DEFAULT '0' COMMENT '父菜单id',
`priority` int(5) unsigned NOT NULL COMMENT '显示优先级',
`code` varchar(64) DEFAULT NULL COMMENT '权限code',
`create_id` bigint(11) DEFAULT NULL COMMENT '创建者id',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_id` bigint(11) DEFAULT NULL COMMENT '最近更新者id',
`update_date` datetime DEFAULT NULL COMMENT '最近更新时间',
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志位 1删除 0未删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='菜单表';
ALTER TABLE menu ADD INDEX index_del_flag (del_flag);
DROP TABLE IF EXISTS `menu_role_relation`;
CREATE TABLE `menu_role_relation` (
`menu_id` bigint(20) NOT NULL COMMENT '用户ID',
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`create_id` bigint(11) NOT NULL COMMENT '创建者id',
`create_date` datetime NOT NULL COMMENT '创建时间',
`update_id` bigint(11) DEFAULT NULL COMMENT '最近更新者id',
`update_date` datetime DEFAULT NULL COMMENT '最近更新时间',
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志位 1删除 0未删除',
PRIMARY KEY (`id`),
KEY `idx_role_id` (`role_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='菜单-角色关系表';
ALTER TABLE menu_role_relation ADD INDEX index_del_flag (del_flag);
INSERT INTO `user_info` (`id`, `user_name`, `real_name`, `password`, `salt`, `status`, `super_admin`, `last_login_time`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`) VALUES ('1', 'mars', 'mars', 'f1a65d566b294b8db222cf61b3b28f72', '3bb81260d3941f5818e72dff4b1342f8', '1', '1', NULL, '1', '2020-09-11 23:40:18', NULL, NULL, '0');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('1', '用户管理', '1', '', '0', '100', NULL, '2019-12-08 13:29:27', '1', '2020-09-12 21:19:14', '0', NULL);
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('2', '用户列表', '2', '/user/index', '1', '101', NULL, '2019-12-08 13:29:49', '1', '2020-09-12 21:19:23', '0', NULL);
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('13', '用户列表-修改密码', '3', '', '2', '102', '1', '2020-09-12 21:43:55', NULL, NULL, '0', 'user:reset:pwd');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('14', '用户列表-新增用户', '3', '', '2', '103', '1', '2020-09-12 21:45:05', NULL, NULL, '0', 'user:list:add');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('15', '用户列表-编辑用户', '3', '', '2', '104', '1', '2020-09-12 21:45:41', NULL, NULL, '0', 'user:list:edit');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('16', '用户列表-删除用户', '3', '', '2', '105', '1', '2020-09-12 21:54:11', NULL, NULL, '0', 'user:list:del');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('17', '用户列表-查看详情', '3', '', '2', '106', '1', '2020-09-12 21:55:55', '1', '2020-09-12 22:39:10', '0', '');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('18', '用户列表-查询全部', '3', '', '2', '107', '1', '2020-09-12 21:56:51', NULL, NULL, '0', 'user:list:list');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('3', '菜单管理', '1', '', '0', '200', NULL, '2019-12-08 14:20:46', '1', '2020-09-12 22:34:12', '0', '');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('4', '菜单列表', '2', '/admin/menu/index', '3', '201', NULL, '2019-12-08 14:21:08', '1', '2020-09-12 22:34:21', '0', '');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('19', '菜单列表-新增', '3', '', '4', '202', '1', '2020-09-12 22:34:05', NULL, NULL, '0', 'menu:list:add');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('20', '菜单列表-编辑', '3', '', '4', '203', '1', '2020-09-12 22:35:35', NULL, NULL, '0', 'menu:list:edit');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('21', '菜单列表-删除', '3', '', '4', '204', '1', '2020-09-12 22:36:17', NULL, NULL, '0', 'menu:list:del');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('22', '菜单列表-查看详情', '3', '', '4', '205', '1', '2020-09-12 22:37:23', NULL, NULL, '0', 'menu:list:info');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('23', '菜单列表-列表', '3', '', '4', '206', '1', '2020-09-12 22:37:59', NULL, NULL, '0', 'menu:list:list');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('8', '权限管理', '1', '', '0', '400', NULL, '2019-12-08 15:56:09', '1', '2020-09-12 23:32:16', '0', '');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('9', '权限列表', '2', '/role/index', '8', '401', NULL, '2019-12-08 15:56:37', '1', '2020-09-12 23:32:21', '0', '');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('34', '权限列表-列表', '3', '', '9', '402', '1', '2020-09-12 23:32:52', NULL, NULL, '0', 'role:list:list');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('35', '权限列表-详情', '3', '', '9', '403', '1', '2020-09-12 23:33:24', NULL, NULL, '0', 'role:list:info');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('36', '权限列表-新增', '3', '', '9', '404', '1', '2020-09-12 23:33:56', NULL, NULL, '0', 'role:list:add');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('37', '权限列表-编辑', '3', '', '9', '405', '1', '2020-09-12 23:34:24', NULL, NULL, '0', 'role:list:edit');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('38', '权限列表-删除', '3', '', '9', '406', '1', '2020-09-12 23:35:00', NULL, NULL, '0', 'role:list:del');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('39', '权限列表-菜单权限', '3', '', '9', '407', '1', '2020-09-12 23:39:59', NULL, NULL, '0', 'role:list:update:menu');
INSERT INTO `menu` (`id`, `menu_name`, `menu_level`, `menu_url`, `parent_menu_id`, `priority`, `create_id`, `create_date`, `update_id`, `update_date`, `del_flag`, `code`) VALUES ('40', '权限列表-动态配置权限', '3', '', '9', '408', '1', '2020-09-12 23:43:09', '1', '2020-09-12 23:43:42', '0', 'role:list:update:role');
| true
|
980fdc22201264f3e6f897a7dcac175b24efc30e
|
SQL
|
basicinside/heartbeat-monitor
|
/sql/schema.sql
|
UTF-8
| 31,523
| 2.953125
| 3
|
[] |
no_license
|
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: antennas; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE antennas (
id integer NOT NULL,
name character varying(255),
vendor character varying(255),
polarity character varying(255),
type character varying(255),
height integer,
direction integer,
gain integer,
angle_horizontal integer,
angle_vertical integer,
created_at date,
updated_at date
);
ALTER TABLE public.antennas OWNER TO robin;
--
-- Name: antennas_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE antennas_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.antennas_id_seq OWNER TO robin;
--
-- Name: antennas_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE antennas_id_seq OWNED BY antennas.id;
--
-- Name: authentications; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE authentications (
id integer NOT NULL,
provider character varying(255),
user_id integer,
uid character varying(255),
created_at timestamp without time zone,
updated_at timestamp without time zone
);
ALTER TABLE public.authentications OWNER TO robin;
--
-- Name: authentications_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE authentications_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.authentications_id_seq OWNER TO robin;
--
-- Name: authentications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE authentications_id_seq OWNED BY authentications.id;
--
-- Name: bugreports; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE bugreports (
id integer NOT NULL,
name character varying(255),
version character varying(255),
device_id integer,
beschreibung text,
uci text,
created_at date,
updated_at date
);
ALTER TABLE public.bugreports OWNER TO robin;
--
-- Name: bugreports_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE bugreports_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.bugreports_id_seq OWNER TO robin;
--
-- Name: bugreports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE bugreports_id_seq OWNED BY bugreports.id;
--
-- Name: nodes; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE nodes (
id integer NOT NULL,
name character varying(255),
node_id character varying(255),
lat numeric,
lon numeric,
version character varying(255),
uci text,
last_seen date,
avatar_file_name character varying(255),
avatar_content_type character varying(255),
avatar_file_size integer,
avatar_updated_at date,
user_id integer,
device_id integer,
created_at date,
updated_at date,
default_ipv4 character varying(16),
description text,
photo_file_name character varying(255),
photo_content_type character varying(255),
photo_file_size integer,
model character varying(255) DEFAULT NULL::character varying,
default_ipv6 character varying(50) DEFAULT NULL::character varying
);
ALTER TABLE public.nodes OWNER TO robin;
--
-- Name: traffic_byte_ipv4s; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_byte_ipv4s (
id integer,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at date,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_byte_ipv4s OWNER TO robin;
--
-- Name: byte_count_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW byte_count_per_node AS
SELECT nodes.name, count(*) AS bytes FROM (traffic_byte_ipv4s b JOIN nodes ON ((b.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.byte_count_per_node OWNER TO robin;
--
-- Name: byte_data_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW byte_data_per_node AS
SELECT nodes.name, sum(p.input) AS input, sum(p.forward) AS forward, sum(p.output) AS output FROM (traffic_byte_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.byte_data_per_node OWNER TO robin;
--
-- Name: byte_input_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW byte_input_per_node AS
SELECT nodes.name, sum(p.input) AS input_bytes FROM (traffic_byte_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.byte_input_per_node OWNER TO robin;
--
-- Name: byte_output_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW byte_output_per_node AS
SELECT nodes.name, sum(p.output) AS bytes FROM (traffic_byte_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.byte_output_per_node OWNER TO robin;
--
-- Name: countries; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE countries (
id integer NOT NULL,
name character varying(255),
description text,
created_at date,
updated_at date
);
ALTER TABLE public.countries OWNER TO robin;
--
-- Name: countries_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE countries_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.countries_id_seq OWNER TO robin;
--
-- Name: countries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
--
-- Name: devices; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE devices (
id integer NOT NULL,
name character varying(255),
hersteller character varying(255),
beschreibung text,
link character varying(255),
created_at date,
updated_at date
);
ALTER TABLE public.devices OWNER TO robin;
--
-- Name: devices_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE devices_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.devices_id_seq OWNER TO robin;
--
-- Name: devices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE devices_id_seq OWNED BY devices.id;
--
-- Name: groups; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE groups (
id integer NOT NULL,
name character varying(255),
description text,
homepage character varying(255),
created_at date,
updated_at date
);
ALTER TABLE public.groups OWNER TO robin;
--
-- Name: groups_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE groups_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.groups_id_seq OWNER TO robin;
--
-- Name: groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE groups_id_seq OWNED BY groups.id;
--
-- Name: heartbeats; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE heartbeats (
id integer NOT NULL,
date date,
node_id integer,
neighbors integer,
clients integer,
created_at date,
updated_at date
);
ALTER TABLE public.heartbeats OWNER TO robin;
--
-- Name: heartbeats_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE heartbeats_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.heartbeats_id_seq OWNER TO robin;
--
-- Name: heartbeats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE heartbeats_id_seq OWNED BY heartbeats.id;
--
-- Name: links; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE links (
id integer NOT NULL,
node1 integer,
node2 integer,
quality numeric,
last_seen date
);
ALTER TABLE public.links OWNER TO robin;
--
-- Name: links_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE links_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.links_id_seq OWNER TO robin;
--
-- Name: links_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE links_id_seq OWNED BY links.id;
--
-- Name: locations; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE locations (
id integer NOT NULL,
name character varying(255),
description text,
plz character varying(255),
province_id integer,
created_at date,
updated_at date
);
ALTER TABLE public.locations OWNER TO robin;
--
-- Name: locations_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE locations_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.locations_id_seq OWNER TO robin;
--
-- Name: locations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE locations_id_seq OWNED BY locations.id;
--
-- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE nodes_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.nodes_id_seq OWNER TO robin;
--
-- Name: nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE nodes_id_seq OWNED BY nodes.id;
--
-- Name: open_id_authentication_nonces; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE open_id_authentication_nonces (
id integer NOT NULL,
nonce character varying(255),
created integer
);
ALTER TABLE public.open_id_authentication_nonces OWNER TO robin;
--
-- Name: open_id_authentication_nonces_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE open_id_authentication_nonces_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.open_id_authentication_nonces_id_seq OWNER TO robin;
--
-- Name: open_id_authentication_nonces_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE open_id_authentication_nonces_id_seq OWNED BY open_id_authentication_nonces.id;
--
-- Name: traffic_packet_ipv4s; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_packet_ipv4s (
id integer,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at date,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_packet_ipv4s OWNER TO robin;
--
-- Name: packet_count_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW packet_count_per_node AS
SELECT nodes.name, count(*) AS packets FROM (traffic_packet_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.packet_count_per_node OWNER TO robin;
--
-- Name: packet_data_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW packet_data_per_node AS
SELECT nodes.name, sum(p.input) AS input, sum(p.forward) AS forward, sum(p.output) AS output FROM (traffic_packet_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.packet_data_per_node OWNER TO robin;
--
-- Name: packet_output_per_node; Type: VIEW; Schema: public; Owner: robin
--
CREATE VIEW packet_output_per_node AS
SELECT nodes.name, sum(p.output) AS packets FROM (traffic_packet_ipv4s p JOIN nodes ON ((p.node_id = nodes.id))) GROUP BY nodes.name;
ALTER TABLE public.packet_output_per_node OWNER TO robin;
--
-- Name: parties; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE parties (
id integer NOT NULL,
name character varying(255),
description text,
homepage character varying(255),
created_at date,
updated_at date
);
ALTER TABLE public.parties OWNER TO robin;
--
-- Name: parties_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE parties_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.parties_id_seq OWNER TO robin;
--
-- Name: parties_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE parties_id_seq OWNED BY parties.id;
--
-- Name: photos; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE photos (
id integer NOT NULL,
node_id integer,
data_file_name character varying(255),
data_content_type character varying(255),
data_file_size integer,
data_updated_at date,
created_at date,
updated_at date
);
ALTER TABLE public.photos OWNER TO robin;
--
-- Name: photos_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE photos_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.photos_id_seq OWNER TO robin;
--
-- Name: photos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE photos_id_seq OWNED BY photos.id;
--
-- Name: provinces; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE provinces (
id integer NOT NULL,
name character varying(255),
description text,
homepage character varying(255),
country_id integer,
created_at date,
updated_at date
);
ALTER TABLE public.provinces OWNER TO robin;
--
-- Name: provinces_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE provinces_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.provinces_id_seq OWNER TO robin;
--
-- Name: provinces_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE provinces_id_seq OWNED BY provinces.id;
--
-- Name: roles; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE roles (
id integer NOT NULL,
name character varying(255),
created_at date,
updated_at date
);
ALTER TABLE public.roles OWNER TO robin;
--
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE roles_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.roles_id_seq OWNER TO robin;
--
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE roles_id_seq OWNED BY roles.id;
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE schema_migrations (
version character varying(255) NOT NULL
);
ALTER TABLE public.schema_migrations OWNER TO robin;
--
-- Name: scores; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE scores (
id integer NOT NULL,
node_id integer,
score integer,
variant integer,
created_at date,
updated_at date
);
ALTER TABLE public.scores OWNER TO robin;
--
-- Name: scores_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE scores_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.scores_id_seq OWNER TO robin;
--
-- Name: scores_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE scores_id_seq OWNED BY scores.id;
--
-- Name: services; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE services (
id integer NOT NULL,
node_id integer,
proto character varying(8),
port integer,
state character varying(10),
name character varying(30),
last_seen date
);
ALTER TABLE public.services OWNER TO robin;
--
-- Name: services_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE services_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.services_id_seq OWNER TO robin;
--
-- Name: services_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE services_id_seq OWNED BY services.id;
--
-- Name: traffic_byte_ipv6s; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_byte_ipv6s (
id integer,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at date,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_byte_ipv6s OWNER TO robin;
--
-- Name: traffic_bytes; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_bytes (
id integer NOT NULL,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_bytes OWNER TO robin;
--
-- Name: traffic_bytes_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE traffic_bytes_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.traffic_bytes_id_seq OWNER TO robin;
--
-- Name: traffic_bytes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE traffic_bytes_id_seq OWNED BY traffic_bytes.id;
--
-- Name: traffic_packet_ipv6s; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_packet_ipv6s (
id integer,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at date,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_packet_ipv6s OWNER TO robin;
--
-- Name: traffic_packets; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE traffic_packets (
id integer NOT NULL,
node_id integer,
input integer,
input_udp integer,
input_olsr integer,
input_tcp integer,
input_ftp integer,
input_ssh integer,
input_smtp integer,
input_http integer,
input_https integer,
input_icmp integer,
forward integer,
forward_udp integer,
forward_olsr integer,
forward_tcp integer,
forward_ftp integer,
forward_ssh integer,
forward_smtp integer,
forward_http integer,
forward_https integer,
forward_icmp integer,
output integer,
output_udp integer,
output_olsr integer,
output_tcp integer,
output_ftp integer,
output_ssh integer,
output_smtp integer,
output_http integer,
output_https integer,
output_icmp integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
ALTER TABLE public.traffic_packets OWNER TO robin;
--
-- Name: traffic_packets_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE traffic_packets_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.traffic_packets_id_seq OWNER TO robin;
--
-- Name: traffic_packets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE traffic_packets_id_seq OWNED BY traffic_packets.id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: robin; Tablespace:
--
CREATE TABLE users (
id integer NOT NULL,
email character varying(255) DEFAULT ''::character varying NOT NULL,
encrypted_password character varying(128) DEFAULT ''::character varying NOT NULL,
reset_password_token character varying(255),
reset_password_sent_at timestamp without time zone,
remember_created_at timestamp without time zone,
sign_in_count integer DEFAULT 0,
current_sign_in_at timestamp without time zone,
last_sign_in_at timestamp without time zone,
current_sign_in_ip character varying(255),
last_sign_in_ip character varying(255),
created_at timestamp without time zone,
updated_at timestamp without time zone,
group_id integer,
party_id integer,
location_id integer,
username character varying(255)
);
ALTER TABLE public.users OWNER TO robin;
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: robin
--
CREATE SEQUENCE users_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE public.users_id_seq OWNER TO robin;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robin
--
ALTER SEQUENCE users_id_seq OWNED BY users.id;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE antennas ALTER COLUMN id SET DEFAULT nextval('antennas_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE authentications ALTER COLUMN id SET DEFAULT nextval('authentications_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE bugreports ALTER COLUMN id SET DEFAULT nextval('bugreports_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE countries ALTER COLUMN id SET DEFAULT nextval('countries_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE devices ALTER COLUMN id SET DEFAULT nextval('devices_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE groups ALTER COLUMN id SET DEFAULT nextval('groups_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE heartbeats ALTER COLUMN id SET DEFAULT nextval('heartbeats_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE links ALTER COLUMN id SET DEFAULT nextval('links_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE locations ALTER COLUMN id SET DEFAULT nextval('locations_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE nodes ALTER COLUMN id SET DEFAULT nextval('nodes_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE open_id_authentication_nonces ALTER COLUMN id SET DEFAULT nextval('open_id_authentication_nonces_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE parties ALTER COLUMN id SET DEFAULT nextval('parties_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE photos ALTER COLUMN id SET DEFAULT nextval('photos_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE provinces ALTER COLUMN id SET DEFAULT nextval('provinces_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE roles ALTER COLUMN id SET DEFAULT nextval('roles_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE scores ALTER COLUMN id SET DEFAULT nextval('scores_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE services ALTER COLUMN id SET DEFAULT nextval('services_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE traffic_bytes ALTER COLUMN id SET DEFAULT nextval('traffic_bytes_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE traffic_packets ALTER COLUMN id SET DEFAULT nextval('traffic_packets_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: robin
--
ALTER TABLE users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
--
-- Name: antennas_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY antennas
ADD CONSTRAINT antennas_pkey PRIMARY KEY (id);
--
-- Name: authentications_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY authentications
ADD CONSTRAINT authentications_pkey PRIMARY KEY (id);
--
-- Name: bugreports_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY bugreports
ADD CONSTRAINT bugreports_pkey PRIMARY KEY (id);
--
-- Name: countries_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY countries
ADD CONSTRAINT countries_pkey PRIMARY KEY (id);
--
-- Name: devices_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY devices
ADD CONSTRAINT devices_pkey PRIMARY KEY (id);
--
-- Name: groups_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY groups
ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
--
-- Name: heartbeats_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY heartbeats
ADD CONSTRAINT heartbeats_pkey PRIMARY KEY (id);
--
-- Name: links_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY links
ADD CONSTRAINT links_pkey PRIMARY KEY (id);
--
-- Name: locations_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY locations
ADD CONSTRAINT locations_pkey PRIMARY KEY (id);
--
-- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY nodes
ADD CONSTRAINT nodes_pkey PRIMARY KEY (id);
--
-- Name: open_id_authentication_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY open_id_authentication_nonces
ADD CONSTRAINT open_id_authentication_nonces_pkey PRIMARY KEY (id);
--
-- Name: parties_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY parties
ADD CONSTRAINT parties_pkey PRIMARY KEY (id);
--
-- Name: photos_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY photos
ADD CONSTRAINT photos_pkey PRIMARY KEY (id);
--
-- Name: provinces_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY provinces
ADD CONSTRAINT provinces_pkey PRIMARY KEY (id);
--
-- Name: roles_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY roles
ADD CONSTRAINT roles_pkey PRIMARY KEY (id);
--
-- Name: scores_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY scores
ADD CONSTRAINT scores_pkey PRIMARY KEY (id);
--
-- Name: services_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY services
ADD CONSTRAINT services_pkey PRIMARY KEY (id);
--
-- Name: traffic_bytes_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY traffic_bytes
ADD CONSTRAINT traffic_bytes_pkey PRIMARY KEY (id);
--
-- Name: traffic_packets_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY traffic_packets
ADD CONSTRAINT traffic_packets_pkey PRIMARY KEY (id);
--
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: robin; Tablespace:
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: index_photos_on_node_id; Type: INDEX; Schema: public; Owner: robin; Tablespace:
--
CREATE INDEX index_photos_on_node_id ON photos USING btree (node_id);
--
-- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: robin; Tablespace:
--
CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email);
--
-- Name: index_users_on_reset_password_token; Type: INDEX; Schema: public; Owner: robin; Tablespace:
--
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
--
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: robin; Tablespace:
--
CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--
| true
|
61622ab4d59e6bd3611f7fb6ab1000616d572050
|
SQL
|
NeoJax/Bookstore
|
/db/schema.sql
|
UTF-8
| 631
| 3.28125
| 3
|
[
"MIT"
] |
permissive
|
DROP DATABASE IF EXISTS bookstore;
CREATE DATABASE bookstore;
\c bookstore;
CREATE TABLE books (
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
genre VARCHAR(255) NOT NULL,
height INTEGER NOT NULL,
publisher VARCHAR(255) NOT NULL
);
CREATE TABLE users (
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
access VARCHAR(255) NOT NULL
);
CREATE TABLE history (
username VARCHAR(255) NOT NULL,
searchType VARCHAR(255) NOT NULL,
searchTerm VARCHAR(255) NOT NULL
);
\COPY books FROM './db/books.csv' DELIMITER ',' CSV HEADER;
\COPY users FROM './db/users.csv' DELIMITER ',' CSV HEADER;
| true
|
c9168c1233b297a7943e8e490387871bed653984
|
SQL
|
PhilippSalvisberg/plscope-utils
|
/database/demo/demo_script/02_demo_lineage.sql
|
UTF-8
| 11,102
| 3.125
| 3
|
[
"Apache-2.0"
] |
permissive
|
-- 1. parse the insert statement using sys.utl_xml.parsequery
select full_text, parse_util.parse_query(in_parse_user => user, in_query => full_text)
from user_statements
where type = 'INSERT'
and object_name = 'LOAD_FROM_TAB'
and type = 'INSERT';
-- 2. get taget tables via XQuery
select t.schema_name,
t.table_name
from user_statements s
cross join xmltable(q'{
for $tar in /QUERY/FROM/FROM_ITEM
return
<target>
<schemaName>{$tar/SCHEMA/text()}</schemaName>
<tableName>{$tar/TABLE/text()}</tableName>
</target>
}'
passing parse_util.parse_query(in_parse_user => user, in_query => s.full_text)
columns schema_name varchar2(128 char) path '/target/schemaName',
table_name varchar2(128 char) path '/target/tableName'
) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB'
and type = 'INSERT';
-- 3. get target tables from table function
select t.*
from user_statements s
cross join table(parse_util.get_insert_targets(in_parse_user => user, in_sql => s.full_text)) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB';
-- 4. get fully qualified target tables from table functions
select t.*
from user_statements s
cross join table(
dd_util.get_objects(
in_parse_user => user,
in_t_obj => parse_util.get_insert_targets(
in_parse_user => user,
in_sql => s.full_text
)
)
) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB';
-- 5. get subquery from insert statement
select s.full_text,
regexp_substr(s.full_text, '(\s|\()+SELECT\s+(.+)', 1, 1, 'i') as subquery
from user_statements s
cross join table(
dd_util.get_objects(
in_parse_user => user,
in_t_obj => parse_util.get_insert_targets(
in_parse_user => user,
in_sql => s.full_text
)
)
) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB';
-- 6. get subquery from function, handling more cases (e.g. with_clause, error_logging_clause)
select s.full_text,
parse_util.get_insert_subquery(in_sql => s.full_text) as subquery
from user_statements s
cross join table(
dd_util.get_objects(
in_parse_user => user,
in_t_obj => parse_util.get_insert_targets(
in_parse_user => user,
in_sql => s.full_text
)
)
) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB';
-- 7. parse the subquery using sys.utl_xml.parsequery
select full_text,
parse_util.parse_query(
in_parse_user => user,
in_query => parse_util.get_insert_subquery(in_sql => s.full_text)
)
from user_statements s
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB'
and type = 'INSERT';
-- 8. where-linage of column salary
select t.schema_name,
t.table_name,
t.column_name
from user_statements s
cross join xmltable(q'{
declare function local:analyze-col($col as element()) as element()* {
let $tableAlias := $col/ancestor::QUERY[1]/FROM/FROM_ITEM//TABLE_ALIAS[local-name(..) != 'COLUMN_REF'
and text() = $col/TABLE_ALIAS/text()]
let $tableAliasTable := if ($tableAlias) then (
$tableAlias/preceding::TABLE[1]
) else (
)
let $queryAlias := $col/ancestor::QUERY[1]/FROM/FROM_ITEM//QUERY_ALIAS[local-name(..) != 'COLUMN_REF'
and text() = $col/TABLE_ALIAS/text()]
let $column := $col/COLUMN
let $ret := if ($queryAlias) then (
for $rcol in $col/ancestor::QUERY/WITH/WITH_ITEM[QUERY_ALIAS/text() = $queryAlias/text()]
//SELECT_LIST_ITEM//COLUMN_REF[ancestor::SELECT_LIST_ITEM/COLUMN_ALIAS/text() = $column/text()
or COLUMN/text() = $column/text()]
let $rret := if ($rcol) then (
local:analyze-col($rcol)
) else (
)
return $rret
) else (
let $tables := if ($tableAliasTable) then (
$tableAliasTable
) else (
for $tab in $col/ancestor::QUERY[1]/FROM/FROM_ITEM//*[self::TABLE or self::QUERY_ALIAS]
return $tab
)
for $tab in $tables
return
typeswitch($tab)
case element(QUERY_ALIAS)
return
let $rcol := $col/ancestor::QUERY/WITH/WITH_ITEM[QUERY_ALIAS/text() = $tab/text()]
//SELECT_LIST_ITEM//COLUMN_REF[ancestor::SELECT_LIST_ITEM/COLUMN_ALIAS/text() = $column/text()
or COLUMN/text() = $column/text()]
let $rret := if ($rcol) then (
for $c in $rcol
return local:analyze-col($c)
) else (
)
return $rret
default
return
<column>
<schemaName>
{$tab/../SCHEMA/text()}
</schemaName>
<tableName>
{$tab/text()}
</tableName>
<columnName>
{$column/text()}
</columnName>
</column>
)
return $ret
}; (: avoid premature statement termination in SQL*Plus et al. :)
for $col in //SELECT/SELECT_LIST/SELECT_LIST_ITEM[not(ancestor::SELECT_LIST_ITEM)][$columnPos]//COLUMN_REF
let $res := local:analyze-col($col)
return $res
}'
passing parse_util.parse_query(
in_parse_user => user,
in_query => parse_util.get_insert_subquery(in_sql => s.full_text)
),
3 as "columnPos"
columns schema_name varchar2(128 char) path 'schemaName',
table_name varchar2(128 char) path 'tableName',
column_name varchar2(128 char) path 'columnName'
) t
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB';
-- 9. where-linage of column salary via function hiding XQuery complexity
select l.owner,
l.object_type,
l.object_name,
l.column_name
from all_statements s
cross join table(
lineage_util.get_dep_cols_from_query(
in_parse_user => user,
in_query => parse_util.get_insert_subquery(in_sql => s.full_text),
in_column_pos => 3
)
) l
where s.type = 'INSERT'
and s.object_name = 'LOAD_FROM_TAB'
and type = 'INSERT';
-- 10. where-lineage of all columns via function
select ids.line,
ids.col,
l.from_owner,
l.from_object_type,
l.from_object_name,
l.from_column_name,
l.to_owner,
l.to_object_type,
l.to_object_name,
l.to_column_name
from plscope_identifiers ids
cross join table(
lineage_util.get_dep_cols_from_insert(
in_signature => ids.signature,
in_recursive => 1
)
) l
where ids.type = 'INSERT'
and ids.object_name = 'LOAD_FROM_TAB'
order by to_column_name;
-- 11. where-lineage of all columns via view
select line,
col,
from_owner,
from_object_type,
from_object_name,
from_column_name,
to_owner,
to_object_type,
to_object_name,
to_column_name
from plscope_ins_lineage
where object_name = 'LOAD_FROM_TAB'
order by to_column_name;
-- 12. where-lineage of all insert statements collected by PL/Scope (default behaviour)
select *
from plscope_ins_lineage
order by owner,
object_type,
object_name,
line,
col,
to_object_name,
to_column_name,
from_owner,
from_object_type,
from_object_name,
from_column_name;
-- 13. where-linage of all insert statements without recursive column analysis
exec lineage_util.set_recursive(0);
select *
from plscope_ins_lineage
order by owner,
object_type,
object_name,
line,
col,
to_object_name,
to_column_name,
from_owner,
from_object_type,
from_object_name,
from_column_name;
-- 14. where-linage of all insert statements with recursive column analysis, but show table source only
exec lineage_util.set_recursive(1);
select *
from plscope_ins_lineage
where from_object_type = 'TABLE'
order by owner,
object_type,
object_name,
line,
col,
to_object_name,
to_column_name,
from_owner,
from_object_type,
from_object_name,
from_column_name;
| true
|
f4dc521e9f47e3a1943f8e0938e37d0606c89261
|
SQL
|
DevonEnergyHackathon2018/Team7
|
/Griedy/Griedy/Griedy.DB/Jobs/JobDetail.sql
|
UTF-8
| 506
| 3.40625
| 3
|
[
"MIT"
] |
permissive
|
CREATE TABLE [Jobs].[JobDetail]
(
[JobDetailId] INT NOT NULL IDENTITY,
[JobInstanceId] INT NOT NULL,
[Message] NVARCHAR(MAX),
[TimeStamp] DATETIME NOT NULL,
[Severity] NVARCHAR(10) NOT NULL,
CONSTRAINT [JobDetailKey] PRIMARY KEY ([JobDetailId]),
CONSTRAINT [JobDetailJobInstanceRef] FOREIGN KEY ([JobInstanceId])
REFERENCES [Jobs].[JobInstance]([JobInstanceId]),
CONSTRAINT [JobDetailSeverityCheck] CHECK ([Severity] = 'Info' OR [Severity] = 'Warning' OR [Severity] = 'Error')
)
| true
|
821c0576010e5c5d58fe6103074da8d3dab3850b
|
SQL
|
chibao99/Khoa-luan-tot-nghi-p
|
/QuerryHotel.sql
|
UTF-8
| 4,479
| 3.90625
| 4
|
[] |
no_license
|
-- tìm phiếu đặt phòng khong co trong khoảng ngày
select distinct p.*,pdp.* from PhieuDatPhong as pdp join Phong as p on pdp.maPhong = p.maPhong
where (pdp.ngayDen >= '2020-12-26' or pdp.ngayDi <='2020-12-11')--di-den
-- tìm phiếu đặt phòng trong khoảng ngày neesu null thi cho thue
select p.*, tinhtrang= 1 from PhieuDatPhong as pdp join Phong as p on pdp.maPhong = p.maPhong
where (pdp.ngayDen <= '2020-12-26' and pdp.ngayDi >='2020-12-11') and p.maPhong = 8 --di-den
--tìm phong có tình trạng trống trong khoảng ngày
select * from Phong
except
select p.* from PhieuDatPhong as pdp join Phong as p on pdp.maPhong = p.maPhong
where (pdp.ngayDen <= '2020-12-26' and pdp.ngayDi >='2020-12-11')--đi - đến
-- list pdp cua 1 phong tu ngay den - ngay di -> dsPDP
select pdp.*, kh.hoTen,kh.CMND,
case
when pdp.ngayDi = '2020-10-23' then 4 -- sap check out
when pdp.ngayDen = '2020-10-23' then 2 -- dang check in
when pdp.ngayDen < '2020-10-23' then 3 -- dang su dung
else 1 -- da dat
end as tinhtrang
from PhieuDatPhong as pdp
join Phong as p on pdp.maPhong = p.maPhong
join KhachHang as kh on kh.maKH = pdp.maKH
where (
( pdp.ngayDi >='2020-10-23') -- ngay hien tai
and p.maPhong = 2
)
-- list phong voi tinh trang ngay hien tai ->Hiejen button
select p.*,
case
when ctp.tinhtrang is null then 0
else ctp.tinhtrang
end as tinhtrang
from Phong as p left join
(
select distinct pdp.maPhong,
case
when pdp.maPhieuDatPhong is null then 0 -- trong
when pdp.ngayDen = '2020-11-20' then 2 -- den han check in
when pdp.ngayDi = '2020-11-20' then 4 -- den han check out
else 3 -- dang su dung
end as tinhtrang
from PhieuDatPhong as pdp right join Phong as p on pdp.maPhong = p.maPhong
where ( (pdp.ngayDen <= '2020-11-20' and pdp.ngayDi >='2020-11-20')) --di-den
) as ctp on p.maPhong = ctp.maPhong
order by p.giaPhong ASC
--Câu lệnh đếm số phòng hiện tại
select COUNT(*) as tongSoPhong from Phong
--Sắp xếp phòng theo giá tiền tăng/giảm
select * from Phong Order by giaPhong DESC -- giảm
select * from Phong Order by giaPhong ASC -- tăng
--QUẢN LÝ Khách Hàng
CREATE PROCEDURE QuanLyKhachHang( @ma int, @ten nvarchar(30), @cmnd nvarchar(15),@ngaySinh date, @gioiTinh bit, @sDt nvarchar(15), @Type nvarchar(20) = '' )
AS
BEGIN
IF @Type = 'Insert'
BEGIN
insert into KhachHang(hoTen,CMND, ngaySinh, gioiTinh,sDT) values( @ten, @cmnd, @ngaySinh, @gioiTinh, @sDt)
END
IF @Type = 'Select'
BEGIN
select * from KhachHang
END
IF @Type = 'Update'
BEGIN
UPDATE KhachHang
SET hoTen = @ten, CMND = @cmnd, gioiTinh = @gioiTinh, sDT = @sDt
WHERE KhachHang.maKH = @ma
END
IF @Type = 'Delete'
BEGIN
DELETE From KhachHang
WHERE KhachHang.maKH = @ma
END
end
--QUẢN LÝ DỊCH VỤ
CREATE PROCEDURE QuanLyDichVu ( @ma int, @ten nvarchar(30),@donVi nvarchar(30), @loai nvarchar(30), @soLuongCo int, @giaDV int, @Type nvarchar(20) = '')
AS
BEGIN
IF @Type = 'Insert'
BEGIN
insert into DichVu(tenDV,donVi, loai, soLuongCo,giaDV) values( @ten, @donVi, @loai, @soLuongCo, @giaDV)
END
IF @Type = 'Select'
BEGIN
select * from DichVu
END
IF @Type = 'Update'
BEGIN
UPDATE DichVu
SET tenDV = @ten, donVi = @donVi, loai = @loai, soLuongCo = @soLuongCo, giaDV = @giaDV
WHERE DichVu.maDV = @ma
END
IF @Type = 'Delete'
BEGIN
DELETE From DichVu
WHERE DichVu.maDV = @ma
END
end
select * from NhanVien
-- THỐNG KÊ DOANH THU TỪNG PHÒNG TRONG TỪNG THÁNG
select p.maPhong, p.loaiPhong, tt = SUM(hd.tongTien) from Phong as p
join PhieuDatPhong as pdp on pdp.maPhong = p.maPhong
join HoaDon as hd on hd.maHD = pdp.maPhieuDatPhong
group by p.maPhong, p.loaiPhong,pdp.ngayDen
having DATEPART(mm,pdp.ngayDen) = 11 and DATEPART(yyyy,pdp.ngayDen) = 2020
-- THỐNG KÊ SỐ LƯỢNG PDP TỪNG PHÒNG
select p.maPhong, tt = Count(p.maPhong) from Phong as p
join PhieuDatPhong as pdp on pdp.maPhong = p.maPhong
where DATEPART(MM,pdp.ngayDen) = 11 and DATEPART(yyyy,pdp.ngayDen) = 2020
group by p.maPhong
-- THỐNG KÊ DOANH THU trong ngày
select * from HoaDon
select hd.ngayLapHD,tt = SUM(hd.tongTien) from HoaDon as hd
where DATEPART(MM,hd.ngayLapHD) = 12 and DATEPART(yyyy,hd.ngayLapHD) = 2019
group by hd.ngayLapHD
--Thống kê khách hàng nào đặt nhiều phòng nhất
select top 10 maKH,num=COUNT(maPhieuDatPhong) from PhieuDatPhong
where DATEPART(yyyy,ngayLapPhieu) = 2020
group by maKH
order by num desc
| true
|
02da09b51b62ddacb945b3baf7de1da55e00098d
|
SQL
|
SebasGarcia08/inserts-sql-generator
|
/DDl.sql
|
UTF-8
| 975
| 3.65625
| 4
|
[] |
no_license
|
CREATE TABLE Employee (
empNo INT,
fName VARCHAR(50),
lName VARCHAR(50),
address VARCHAR(100),
DOB DATE,
sex CHAR(1),
position VARCHAR(30),
deptNo INT,
PRIMARY KEY (empNo)
);
CREATE TABLE Department (
deptNo INT,
deptName VARCHAR(50),
mgrEmpNo INT,
PRIMARY KEY (deptNo),
FOREIGN KEY (mgrEmpNo) REFERENCES Employee (empNo) ON DELETE SET NULL
);
CREATE TABLE Project (
projNo INT,
projName VARCHAR(50),
deptNo INT,
PRIMARY KEY (projNo),
FOREIGN KEY (deptNo) REFERENCES Department (deptNo) ON DELETE CASCADE
);
CREATE TABLE WorksOn (
empNo INT,
projNo INT,
dateworked Date,
hoursWorked Number(10,2),
PRIMARY KEY (empNo,projNo,dateworked),
FOREIGN KEY (EmpNo) REFERENCES Employee (EmpNo) ON DELETE SET NULL,
FOREIGN KEY (projNo) REFERENCES Project (projNo) ON DELETE CASCADE
);
ALTER TABLE Employee
ADD CONSTRAINT FK_Department_Employee FOREIGN KEY (deptNo)
REFERENCES Department (deptNo)
ON DELETE CASCADE
;
| true
|
a9e47fae8cc9e8e85369bfb72ce679b68741abfa
|
SQL
|
johnthomson91/sql-challenge
|
/employee_data3.sql
|
UTF-8
| 336
| 3.109375
| 3
|
[] |
no_license
|
--List the manager of each department with the following information:
--department number, department name, the manager's employee number, last name, first name.
select * from dep_manager;
INSERT INTO dep_manager
SELECT
e.dept_no
, e.emp_no
, e.dept_name
, e.last_name
, e.first_name
FROM main_table3 e
;
COMMIT;
| true
|
8186292d67c5c0f869e769ed7bd84435fa3d74a9
|
SQL
|
swcho/ex_sql
|
/30_final/problem.sql
|
UTF-8
| 207
| 2.609375
| 3
|
[] |
no_license
|
select PLAYER_NAME, HEIGHT, WEIGHT from PLAYER_T order by PLAYER_NAME;
create index PLAYER_IDX_PLAYER_NAME on PLAYER_T(PLAYER_NAME);
select PLAYER_NAME, HEIGHT, WEIGHT from PLAYER_T order by PLAYER_NAME;
| true
|
b56864ff53eeb72454f8d4128920e2adfed36004
|
SQL
|
citusdata/pgconfus-tutorial-multi-tenant
|
/setup.sql
|
UTF-8
| 3,238
| 4
| 4
|
[] |
no_license
|
CREATE SCHEMA tutorial;
CREATE TABLE tutorial.users (
user_id uuid NOT NULL DEFAULT uuid_generate_v4(),
email text NOT NULL UNIQUE,
encrypted_password text NOT NULL ,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id)
);
SELECT create_reference_table('tutorial.users');
CREATE TABLE tutorial.stores (
store_id uuid NOT NULL DEFAULT uuid_generate_v4(),
user_id uuid NOT NULL DEFAULT uuid_generate_v4(),
name text NOT NULL,
category text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (store_id)
);
SELECT create_distributed_table('tutorial.stores', 'store_id');
CREATE TABLE tutorial.products (
store_id uuid NOT NULL DEFAULT uuid_generate_v4(),
product_id uuid NOT NULL DEFAULT uuid_generate_v4(),
name text NOT NULL,
description text NOT NULL,
product_details jsonb NOT NULL,
price numeric(20,2) NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (store_id, product_id),
FOREIGN KEY (store_id) REFERENCES tutorial.stores (store_id)
);
SELECT create_distributed_table('tutorial.products', 'store_id');
CREATE TABLE tutorial.orders (
store_id uuid NOT NULL DEFAULT uuid_generate_v4(),
order_id uuid NOT NULL DEFAULT uuid_generate_v4(),
status text NOT NULL,
total_amount numeric(20,2) NOT NULL,
shipping_address text NOT NULL,
billing_address text NOT NULL,
shipping_info jsonb NOT NULL,
ordered_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (store_id, order_id),
FOREIGN KEY (store_id) REFERENCES tutorial.stores (store_id)
);
SELECT create_distributed_table('tutorial.orders', 'store_id');
CREATE TABLE tutorial.line_items (
store_id uuid NOT NULL DEFAULT uuid_generate_v4(),
line_item_id uuid NOT NULL DEFAULT uuid_generate_v4(),
order_id uuid NOT NULL DEFAULT uuid_generate_v4(),
product_id uuid NOT NULL DEFAULT uuid_generate_v4(),
quantity integer NOT NULL,
line_amount numeric(20,2) NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (store_id, line_item_id),
FOREIGN KEY (store_id) REFERENCES tutorial.stores (store_id),
FOREIGN KEY (store_id, order_id) REFERENCES tutorial.orders (store_id, order_id),
FOREIGN KEY (store_id, product_id) REFERENCES tutorial.products (store_id, product_id)
);
SELECT create_distributed_table('tutorial.line_items', 'store_id');
\copy tutorial.users (user_id, email, encrypted_password) FROM 'data/users.csv' WITH (format CSV)
\copy tutorial.stores (store_id, user_id, name, category) FROM 'data/stores.csv' WITH (format CSV)
\copy tutorial.products (store_id, product_id, name, description, product_details, price) FROM 'data/products.csv' WITH (format CSV)
\copy tutorial.orders (store_id, order_id, status, total_amount, shipping_address, billing_address, shipping_info, ordered_at) FROM 'data/orders.csv' WITH (format CSV)
\copy tutorial.line_items (store_id, order_id, product_id, quantity, line_amount) FROM 'data/line_items.csv' WITH (format CSV)
| true
|
532d1b48620ab7910f4a45422f9a67421d1a0d16
|
SQL
|
P79N6A/beidou-report
|
/src/main/archive/database/2.0.0/report.2.0.0.sql
|
UTF-8
| 1,923
| 3.0625
| 3
|
[] |
no_license
|
CREATE DATABASE IF NOT EXISTS `beidoureport` /*!40100 DEFAULT CHARACTER SET utf8 */;
use beidoureport;
CREATE TABLE `stat_user_yest` (
`userid` int(10) NOT NULL,
`srchs` bigint(20) NOT NULL,
`clks` int(11) NOT NULL,
`cost` int(11) NOT NULL,
UNIQUE KEY `userid` (`userid`),
KEY `cost` (`cost`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `stat_plan_yest` (
`userid` int(10) NOT NULL,
`planid` int(10) NOT NULL,
`srchs` bigint(20) NOT NULL,
`clks` int(11) NOT NULL,
`cost` int(11) NOT NULL,
UNIQUE KEY `planid` (`planid`),
KEY `userid` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `stat_group_yest` (
`userid` int(10) NOT NULL,
`planid` int(10) NOT NULL,
`groupid` int(10) NOT NULL,
`srchs` bigint(20) NOT NULL,
`clks` int(11) NOT NULL,
`cost` int(11) NOT NULL,
UNIQUE KEY `groupid` (`groupid`),
KEY `userid` (`userid`),
KEY `planid` (`planid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `stat_unit_yest` (
`userid` int(10) NOT NULL,
`planid` int(10) NOT NULL,
`groupid` int(10) NOT NULL,
`unitid` bigint(20) NOT NULL,
`srchs` bigint(20) NOT NULL,
`clks` int(11) NOT NULL,
`cost` int(11) NOT NULL,
UNIQUE KEY `unitid` (`unitid`),
KEY `userid` (`userid`),
KEY `planid` (`planid`),
KEY `groupid` (`groupid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `stat_user_all` (
`userid` int(10) NOT NULL,
`srchs` bigint(20) NOT NULL,
`clks` int(11) NOT NULL,
`cost` int(11) NOT NULL,
UNIQUE KEY `userid` (`userid`),
KEY `cost` (`cost`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `sysnvtab` (
`name` varchar(64) collate utf8_bin NOT NULL,
`value` text collate utf8_bin,
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
| true
|
025550647a3d6ebac2d5a4de285b9fb32a732bab
|
SQL
|
CherryProject/CherryProject
|
/CherryProject/src/main/resources/sqlFiles/Oracle_CreateTable.sql
|
UTF-8
| 5,782
| 3.96875
| 4
|
[] |
no_license
|
-- BusinessCard Project 테이블 생성 및 샘플 데이터 입력 sql
-- 2018.03.30. 정보승
-- 회원정보 TABLE
CREATE TABLE tbl_userinfo (
userid VARCHAR2(50) PRIMARY KEY -- 회원 ID
, userpw VARCHAR2(100) NOT NULL -- 회원 비밀번호
, username VARCHAR2(100) NOT NULL -- 회원 이름
, emailverify CHAR(1) DEFAULT 'N' -- 이메일 인증
);
COMMIT;
--ALTER TABLE
-- tbl_userinfo
--ADD (
-- emailverify char(1) DEFAULT 'N'
--);
-- 본인 명함 관리 TABLE
CREATE TABLE tbl_mycardinfo (
mycardnum VARCHAR2(100) PRIMARY KEY -- 명함 등록 번호 : 식별자를 통해 제작 명함과 등록 명함을 구분 (ex. m01 : 제작, m11:등록, c01: 받은 명함)
, userid VARCHAR2(50) -- 회원 ID : 회원정보 TABLE의 useid를 참조.
, company VARCHAR2(100) -- 회사명
, name1 VARCHAR2(100) -- 성명
, name2 VARCHAR2(100) -- 성명
, name3 VARCHAR2(100) -- 성명
, phone VARCHAR2(100) -- 연락처
, tel VARCHAR2(100) -- 회사 전화번호
, fax VARCHAR2(100) -- 팩스 번호
, email VARCHAR2(100) -- E-mail 주소
, address VARCHAR2(200) -- 회사 주소
, job VARCHAR2(100) -- 직책, 직위, 직급
, department VARCHAR2(100) -- 부서명
, otherinfo VARCHAR2(200) -- 기타 정보
, frontimgsaved VARCHAR2(300) NOT NULL -- 명함 앞면의 이미지 경로
, backimgsaved VARCHAR2(300) -- 명함 뒷면의 이미지 경로
, cardorder NUMBER DEFAULT 0 -- 명함의 순서(현재 사용하고 있는 명함의 숫자가 가장 크다)
, frontimgoriginal VARCHAR2(300) --
, backimgoriginal VARCHAR2(300) --
);
COMMIT;
-- 외래키 등록
ALTER TABLE
tbl_mycardinfo
ADD CONSTRAINT
FK_tbl_mycardinfo_userid FOREIGN KEY(userid)
REFERENCES
tbl_userinfo(userid);
COMMIT;
-- 받은 명함 관리 TABLE
CREATE TABLE tbl_yourcardinfo (
yourcardnum VARCHAR2(100) PRIMARY KEY -- 다른 사람에게 받은 명함의 등록번호 : 받은 사람의 명함 등록 번호를 따로 부여 (ex. c01: 받은 명함)
, userid VARCHAR2(50) NOT NULL -- 회원 ID : 회원정보 TABLE의 useid를 참조
, yournum VARCHAR2(50) NOT NULL -- 명함을 준 사람들의 번호 : 받은 사람의 번호를 부여해서 명함을 그룹화(동명이인의 경우를 대비) (ex. you01)
, mycardnum VARCHAR2(100) NOT NULL -- 내 명함의 등록 번호 : 본인 명함 관리 TABLE의 mycardnum을 참조
, memo VARCHAR2(500) -- 간단한 메모를 저장
, company VARCHAR2(100) -- 회사명
, name1 VARCHAR2(100) -- 성명
, name2 VARCHAR2(100) -- 성명
, name3 VARCHAR2(100) -- 성명
, phone VARCHAR2(100) -- 연락처
, tel VARCHAR2(100) -- 회사 전화번호
, fax VARCHAR2(100) -- 팩스 번호
, email VARCHAR2(100) -- E-mail 주소
, address VARCHAR2(200) -- 회사 주소
, job VARCHAR2(100) -- 직책, 직위, 직급
, department VARCHAR2(100) -- 부서명
, otherinfo VARCHAR2(200) -- 기타 정보
, frontimgsaved VARCHAR2(300) NOT NULL -- 명함 앞면의 이미지 경로 : OCR로 판독하기 위한 사진의 앞쪽 명함 이미지 경로
, backimgsaved VARCHAR2(300) -- 명함 뒷면의 이미지 경로 : OCR로 판독하기 위한 사진의 뒤쪽 명함 이미지 경로
, cardorder NUMBER DEFAULT 0 -- 명함의 순서(현재 사용하고 있는 명함의 숫자가 가장 크다)
, sex CHAR(1) DEFAULT 'M'
, frontimgoriginal VARCHAR2(300)
, backimgoriginal VARCHAR2(300)
);
COMMIT;
-- 외래키 등록
ALTER TABLE
tbl_yourcardinfo
ADD CONSTRAINT
FK_tbl_yourcardinfo_userid FOREIGN KEY(userid)
REFERENCES
tbl_userinfo(userid);
ALTER TABLE
tbl_yourcardinfo
ADD CONSTRAINT
FK_tbl_yourcardinfo_mycardnum FOREIGN KEY(mycardnum)
REFERENCES
tbl_mycardinfo(mycardnum);
COMMIT;
CREATE SEQUENCE seq_yourcardnum START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE seq_yournum START WITH 1 INCREMENT BY 1;
COMMIT;
-- 레이아웃 TABLE : 명함등록 번호 및 레이아웃 구분번호는 기본적으로 입력된다.
-- 배경이미지의 경우 : x, y, z 위치 값, (이미지 경로)만 입력
-- 텍스트의 경우 : 위의 경우 포함 및 글자체, 글자크기, 객체 색, 회전, 메모까지의 입력
-- 일반 이미지(템플릿, 아이콘, 로고 모두 포함) : 글자체와 글자크기, 메모만 제외한 모든 값 입력
CREATE TABLE tbl_cardlayout (
layoutnum NUMBER PRIMARY KEY -- 의미없는 구분 번호 Sequence
, mycardnum VARCHAR2(100) -- 내 명함의 등록 번호 : 본인 명함 관리 TABLE의 mycardnum을 참조
, xposition NUMBER NOT NULL -- x위치
, yposition NUMBER NOT NULL -- y위치
, zposition NUMBER DEFAULT 1 -- z위치 : 레이아웃의 겹쳐지는 높이를 의미. 배경이미지 값이 0
, font VARCHAR2(50) -- 글자체
, fontsize NUMBER -- 글차크기
, fontcolor VARCHAR2(100) -- 객체의 색 : 글자의 경우 폰트의 색, 이미지의 경우 배경의 색
, rotation NUMBER DEFAULT 0 -- 객체의 회전각도
, backgrimg VARCHAR2(300) -- 이미지, 템플릿 경로
, memo VARCHAR2(100) -- 텍스트 박스의 경우 텍스트 내용을 저장. 이 값이 null이면 이미지, 템플릿
);
COMMIT;
ALTER TABLE
tbl_cardlayout
ADD CONSTRAINT
FK_tbl_cardlayout_mycardnum FOREIGN KEY(mycardnum)
REFERENCES
tbl_mycardinfo(mycardnum);
COMMIT;
-- 시퀀스 생성
CREATE SEQUENCE seq_layoutnum START WITH 1 INCREMENT BY 1;
COMMIT;
CREATE SEQUENCE seq_mycardnum START WITH 1 INCREMENT BY 1;
| true
|
32c0f51d4e3879b0627ae40da5300e06f20f47c4
|
SQL
|
CodechefVaibhav/helpJsp
|
/src/mydatabase.sql
|
UTF-8
| 2,694
| 3.25
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 17, 2014 at 10:31 AM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `mydatabase`
--
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE IF NOT EXISTS `employee` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) DEFAULT NULL,
`company` varchar(20) DEFAULT NULL,
`designation` varchar(20) DEFAULT NULL,
`exp` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`id`, `name`, `company`, `designation`, `exp`) VALUES
(1, 'DIMPLE CHADHA', 'TCS', 'TECHNICAL LEAD', 5),
(2, 'NEHA GOEL', 'HCL', 'PROJECT MANAGER', 12),
(3, 'AMIT JOSHI', 'IBM', 'TECHNICAL LEAD', 7),
(4, 'KUNAL CHADHA', 'TCS', 'SOFTWARE ENGINEER', 3),
(5, 'SAKSHI DHINGRA', 'IBM', 'BUSINESS ANALYST', 4),
(6, 'RAHUL GULATI', 'SAPIENT', 'TECHNICAL LEAD', 5),
(7, 'SHILPA MANGLA', 'INFOGAIN', 'BUSINESS ANALYST', 5),
(8, 'MANYATA DUTT', 'ORACLE', 'SOFTWARE ENGINEER', 6),
(9, 'SACHIN KUMAR', 'MICROSOFT', 'PROJECT MANAGER', 10),
(10, 'ANKIT MORE', 'GOOGLE', 'SOFTWARE ENGINEER', 1),
(12, 'neeru', 'xyz', 'data analyst', 1),
(13, 'priya', 'sus', 'ser', 2345);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`gender` varchar(50) NOT NULL,
`city` varchar(50) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=914 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`user_id`, `first_name`, `last_name`, `gender`, `city`) VALUES
(1, 'vaibhav', 'kashyap', 'Male', 'Delhi'),
(906, 'Ankush', 'Thakur', 'male', 'gurgaon'),
(907, 'Anamika', 'Singh', 'female', 'meerut'),
(908, 'Shweta', 'Gupta', 'female', 'gurgaon'),
(909, 'Rajesh', 'Chauhan', 'male', 'noida'),
(911, 'Andrew', 'Symonds', 'male', 'delhi'),
(912, 'vaibhav', 'kashyap', 'Male', 'Delhi'),
(913, 'anvesh', 'saxena', 'Male', 'Bangalore');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
027daf351e0b094cd78dcc1f479915cc7e1cbdde
|
SQL
|
johnray10/Library_Management_System
|
/librarydb.sql
|
UTF-8
| 4,775
| 3.390625
| 3
|
[] |
no_license
|
/*
SQLyog Community v13.1.5 (64 bit)
MySQL - 10.1.36-MariaDB : Database - librarydb
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`librarydb` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `librarydb`;
/*Table structure for table `account` */
DROP TABLE IF EXISTS `account`;
CREATE TABLE `account` (
`USER_ID` int(11) NOT NULL AUTO_INCREMENT,
`FIRSTNAME` varchar(100) NOT NULL,
`LASTNAME` varchar(100) NOT NULL,
`MIDDLENAME` varchar(100) NOT NULL,
`CONTACT` varchar(11) NOT NULL,
`USERNAME` varchar(100) NOT NULL,
`PASSWORD` varchar(100) NOT NULL,
`GENDER` varchar(6) NOT NULL,
`SECRET_QUESTION` varchar(100) NOT NULL,
`SECRET_ANSWER` varchar(100) NOT NULL,
`TYPE_OF_PERMISSION` varchar(100) NOT NULL,
`DATE_OF_BIRTH` varchar(50) NOT NULL,
`Date_Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`USER_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
/*Data for the table `account` */
/*Table structure for table `audit` */
DROP TABLE IF EXISTS `audit`;
CREATE TABLE `audit` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`USERNAME` varchar(100) NOT NULL,
`PERMISSION` varchar(100) NOT NULL,
`LOG_IN` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*Data for the table `audit` */
/*Table structure for table `books` */
DROP TABLE IF EXISTS `books`;
CREATE TABLE `books` (
`ISBN` varchar(50) NOT NULL,
`TITLE` varchar(100) NOT NULL,
`AUTHOR` varchar(50) NOT NULL,
`CATEGORY_BOOK` varchar(50) NOT NULL,
`EDITION` varchar(50) NOT NULL,
`PUBLICATION` varchar(50) NOT NULL,
`PUBLICATION_YEAR` varchar(4) NOT NULL,
`TOTAL_BOOKS` varchar(10) NOT NULL,
`AMOUNT` varchar(10) NOT NULL,
`TOTAL_BORROWED` varchar(10) NOT NULL,
`DATE_CREATED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`MARKS` int(11) NOT NULL,
PRIMARY KEY (`ISBN`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `books` */
/*Table structure for table `borrow` */
DROP TABLE IF EXISTS `borrow`;
CREATE TABLE `borrow` (
`RECORDNO` varchar(50) NOT NULL,
`LIBRARYID` varchar(50) NOT NULL,
`STUDENTID` varchar(50) NOT NULL,
`FULLNAME` varchar(100) NOT NULL,
`BOOKID` varchar(50) NOT NULL,
`BOOK_TITLE` varchar(100) NOT NULL,
`CATEGORY_BOOK` varchar(100) NOT NULL,
`ISSUES_DATE` varchar(50) NOT NULL,
`RETURN_DATE` varchar(50) NOT NULL,
`MARKS` int(11) NOT NULL,
PRIMARY KEY (`RECORDNO`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `borrow` */
/*Table structure for table `login_history` */
DROP TABLE IF EXISTS `login_history`;
CREATE TABLE `login_history` (
`USER` int(11) NOT NULL AUTO_INCREMENT,
`USERNAME` varchar(100) NOT NULL,
`TIME_OUT` varchar(50) NOT NULL,
`DATE_OUT` varchar(50) NOT NULL,
PRIMARY KEY (`USER`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
/*Data for the table `login_history` */
/*Table structure for table `returns` */
DROP TABLE IF EXISTS `returns`;
CREATE TABLE `returns` (
`RETURNID` int(11) NOT NULL AUTO_INCREMENT,
`RECORD_NO` varchar(50) NOT NULL,
`LIBRARYID` varchar(50) NOT NULL,
`STUDENT_NO` varchar(50) NOT NULL,
`BOOKNAME` varchar(100) NOT NULL,
`LATEDAYS` int(50) NOT NULL,
`CHARGES` double NOT NULL,
`DATE_RECORD` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`RETURNID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*Data for the table `returns` */
/*Table structure for table `student` */
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`LIBRARY_ID` varchar(50) NOT NULL,
`STUDENT_ID` varchar(50) NOT NULL,
`FIRSTNAME` varchar(100) NOT NULL,
`LASTNAME` varchar(100) NOT NULL,
`MIDDLENAME` varchar(100) NOT NULL,
`COURSE` varchar(100) NOT NULL,
`YEAR` varchar(100) NOT NULL,
`EDUC` varchar(100) NOT NULL,
`CONTACT` varchar(11) NOT NULL,
`TODAY` text NOT NULL,
`GENDER` varchar(10) NOT NULL,
`ADDRESS` text NOT NULL,
PRIMARY KEY (`LIBRARY_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `student` */
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
| true
|
98d0b39c885217ed1a09b279f84eacf8b2f19289
|
SQL
|
har-ki/anahita
|
/packages/Sightings/src/administrator/components/com_sightings/schemas/migrations/1.sql
|
UTF-8
| 290
| 2.71875
| 3
|
[
"Apache-2.0"
] |
permissive
|
CREATE TABLE IF NOT EXISTS `#__sightings_sightings` (
`sightings_sighting_id` bigint(20) NOT NULL auto_increment,
`node_id` bigint(11) NOT NULL,
PRIMARY KEY (`sightings_sighting_id`),
UNIQUE KEY `node_id` (`node_id`)
) ENGINE=InnoDB CHARACTER SET `utf8` COLLATE `utf8_general_ci`;
| true
|
3de8e786f46ea5f24cbe2c00a2be97a8a99c6a4e
|
SQL
|
rvyshnivskyi/car-sale
|
/src/main/resources/database/queries.sql
|
UTF-8
| 1,404
| 4.28125
| 4
|
[] |
no_license
|
--------------------------------------------------------------------------------
--- List of cars available on sale with the best deal proposed at the moment;
--------------------------------------------------------------------------------
SELECT c.id, c.plate_number, c.brand, c.year, c.color, MAX(o.price) FROM car c INNER JOIN sale_proposition s
ON c.id = s.car_id INNER JOIN offer o
ON s.id = o.sale_proposition_id
GROUP BY c.id, c.plate_number, c.brand, c.year, c.color;
--------------------------------------------------------------------------------
--- The most expensive sold car;
--------------------------------------------------------------------------------
SELECT c.id, c.plate_number, c.brand, c.year, c.color, o.price FROM car c INNER JOIN sale_proposition s
ON c.id = s.car_id INNER JOIN offer o
ON s.id = o.sale_proposition_id
WHERE o.status = 'Accepted' AND s.status = 'Closed'
ORDER BY o.price DESC
LIMIT 1;
--------------------------------------------------------------------------------
--- The most popular year of sold cars;
--------------------------------------------------------------------------------
SELECT c.year, count(*) as count FROM car c INNER JOIN sale_proposition s
ON c.id = s.car_id INNER JOIN offer o
ON s.id = o.sale_proposition_id
WHERE o.status = 'Accepted' AND s.status = 'Closed'
GROUP BY c.year
ORDER BY count DESC
LIMIT 1;
| true
|
d250f826a4a864689950e0410fc7eab5ba234564
|
SQL
|
jonananas/tdd-the-database
|
/create_db.sql
|
UTF-8
| 246
| 3.25
| 3
|
[] |
no_license
|
CREATE SCHEMA IF NOT EXISTS APPSCHEMA;
CREATE TABLE IF NOT EXISTS "APPSCHEMA"."PERSON"
(
ID VARCHAR(36) NOT NULL,
CONSTRAINT PK_PERSONID PRIMARY KEY (ID)
);
CREATE UNIQUE INDEX IF NOT EXISTS PK_PERSONID ON "APPSCHEMA"."PERSON"
(
ID
);
| true
|
99addad64315f6f93a9aad86346bc849a0898fb1
|
SQL
|
TheSlavaHero/Blu
|
/src/main/resources/database/initDB.sql
|
UTF-8
| 613
| 2.65625
| 3
|
[] |
no_license
|
drop table if exists clients;
create table clients
(
id serial not null
constraint clients_pkey
primary key,
name varchar(255) not null,
surname varchar(255) not null,
password varchar(255) not null,
role varchar(255) not null,
email varchar(255) not null,
phone varchar(255) default NULL::character varying,
age varchar(255) default NULL::character varying,
authkey varchar(255) default NULL::character varying
-- card varchar(255) default NULL::character varying
);
CREATE SEQUENCE hibernate_sequence START 1;
| true
|
027fe8b53f43e9072528300fd066228b76813718
|
SQL
|
alin-tandea/ClinicApp
|
/init.sql
|
UTF-8
| 11,266
| 3.703125
| 4
|
[] |
no_license
|
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema assignment3
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `assignment3` ;
-- -----------------------------------------------------
-- Schema assignment3
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `assignment3` DEFAULT CHARACTER SET utf8 ;
USE `assignment3` ;
-- -----------------------------------------------------
-- Table `assignment3`.`User`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`User` (
`id` INT NOT NULL AUTO_INCREMENT,
`username` VARCHAR(45) NOT NULL,
`password` VARCHAR(45) NOT NULL,
`fullName` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `username_UNIQUE` (`username` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Role`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Role` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Patient`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Patient` (
`id` INT NOT NULL AUTO_INCREMENT,
`fullName` VARCHAR(45) NOT NULL,
`idCardSeries` VARCHAR(2) NOT NULL,
`idCardNumber` VARCHAR(6) NOT NULL,
`personalNumericalCode` VARCHAR(13) NOT NULL,
`address` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `personalNumericalCode_UNIQUE` (`personalNumericalCode` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`User_has_Role`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`User_has_Role` (
`User_id` INT NOT NULL,
`Role_id` INT NOT NULL,
PRIMARY KEY (`User_id`, `Role_id`),
INDEX `fk_User_has_Role_Role1_idx` (`Role_id` ASC),
INDEX `fk_User_has_Role_User_idx` (`User_id` ASC),
CONSTRAINT `fk_User_has_Role_User`
FOREIGN KEY (`User_id`)
REFERENCES `assignment3`.`User` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_User_has_Role_Role1`
FOREIGN KEY (`Role_id`)
REFERENCES `assignment3`.`Role` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Doctor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Doctor` (
`id` INT NOT NULL,
INDEX `fk_Doctor_User1_idx` (`id` ASC),
PRIMARY KEY (`id`),
CONSTRAINT `fk_Doctor_User1`
FOREIGN KEY (`id`)
REFERENCES `assignment3`.`User` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`WorkingHour`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`WorkingHour` (
`id` INT NOT NULL AUTO_INCREMENT,
`startHour` INT NOT NULL,
`endHour` INT NOT NULL,
`dayOfWeek` INT NOT NULL,
`doctorId` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_WorkingHour_Doctor1_idx` (`doctorId` ASC),
CONSTRAINT `fk_WorkingHour_Doctor1`
FOREIGN KEY (`doctorId`)
REFERENCES `assignment3`.`Doctor` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Consultation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Consultation` (
`id` INT NOT NULL AUTO_INCREMENT,
`patientId` INT NOT NULL,
`startsAt` DATETIME NOT NULL,
`endsAt` DATETIME NOT NULL,
`doctorId` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_Consultation_Patient1_idx` (`patientId` ASC),
INDEX `fk_Consultation_Doctor1_idx` (`doctorId` ASC),
CONSTRAINT `fk_Consultation_Patient1`
FOREIGN KEY (`patientId`)
REFERENCES `assignment3`.`Patient` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_Consultation_Doctor1`
FOREIGN KEY (`doctorId`)
REFERENCES `assignment3`.`Doctor` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Notification`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Notification` (
`id` INT NOT NULL AUTO_INCREMENT,
`seen` TINYINT(1) NOT NULL,
`reference` INT NOT NULL,
`text` VARCHAR(100) NULL,
`createdAt` DATETIME NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_Notification_Consultation1_idx` (`reference` ASC),
CONSTRAINT `fk_Notification_Consultation1`
FOREIGN KEY (`reference`)
REFERENCES `assignment3`.`Consultation` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `assignment3`.`Observation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `assignment3`.`Observation` (
`id` INT NOT NULL AUTO_INCREMENT,
`consultationId` INT NOT NULL,
`text` VARCHAR(255) NOT NULL,
`createdAt` DATETIME NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_Observation_Consultation1_idx` (`consultationId` ASC),
CONSTRAINT `fk_Observation_Consultation1`
FOREIGN KEY (`consultationId`)
REFERENCES `assignment3`.`Consultation` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
DELIMITER //
DROP TRIGGER IF EXISTS delete_doctor_trigger//
CREATE TRIGGER delete_doctor_trigger
AFTER DELETE ON `user_has_role`
FOR EACH ROW
BEGIN
DECLARE doctor_role INT;
SET doctor_role = (SELECT id FROM assignment3.role WHERE name="doctor");
if OLD.Role_id = doctor_role THEN
DELETE FROM doctor WHERE ID = OLD.User_id;
END IF;
END//
DELIMITER ;
DELIMITER //
DROP TRIGGER IF EXISTS insert_doctor_trigger//
CREATE TRIGGER insert_doctor_trigger
AFTER INSERT ON `user_has_role`
FOR EACH ROW
BEGIN
DECLARE exist INT;
DECLARE doctor_role INT;
SET doctor_role = (SELECT id FROM assignment3.role WHERE name="doctor");
if NEW.Role_id = doctor_role THEN
SET exist = (SELECT id FROM assignment3.doctor WHERE id=NEW.User_id);
if exist IS NULL THEN
INSERT INTO doctor(`id`) VALUES (NEW.User_id);
END IF;
END IF;
END//
DELIMITER ;
INSERT INTO `assignment3`.`user` (`username`, `password`, `fullName`) VALUES ('admin', 'admin', 'Administrator');
INSERT INTO `assignment3`.`user` (`username`, `password`, `fullName`) VALUES ('secretary', 'secretary', 'Secretary');
INSERT INTO `assignment3`.`user` (`username`, `password`, `fullName`) VALUES ('doctor1', 'doctor1', 'Doctor One');
INSERT INTO `assignment3`.`user` (`username`, `password`, `fullName`) VALUES ('doctor2', 'doctor2', 'Doctor Two');
INSERT INTO `assignment3`.`role` (`name`) VALUES ('ADMIN');
INSERT INTO `assignment3`.`role` (`name`) VALUES ('SECRETARY');
INSERT INTO `assignment3`.`role` (`name`) VALUES ('DOCTOR');
INSERT INTO `assignment3`.`user_has_role` (`User_id`, `Role_id`) VALUES ('1', '1');
INSERT INTO `assignment3`.`user_has_role` (`User_id`, `Role_id`) VALUES ('2', '2');
INSERT INTO `assignment3`.`user_has_role` (`User_id`, `Role_id`) VALUES ('3', '3');
INSERT INTO `assignment3`.`user_has_role` (`User_id`, `Role_id`) VALUES ('4', '3');
INSERT INTO `assignment3`.`workinghour`(`startHour`,`endHour`,`dayOfWeek`,`doctorId`) VALUES
('8', '17', '4', '3'),
('8', '17', '3', '3'),
('8', '17', '1', '3'),
('8', '17', '2', '3'),
('8', '12', '5', '3'),
('14', '17', '5', '3'),
('10', '18', '3', '4'),
('17', '21', '7', '4'),
('10', '18', '2', '4'),
('12', '16', '6', '4'),
('17', '21', '6', '4'),
('12', '16', '7', '4'),
('15', '20', '4', '4'),
('10', '13', '4', '4');
INSERT INTO `assignment3`.`patient` (`fullName`,`idCardSeries`,`idCardNumber`,`personalNumericalCode`,`address`) VALUES
('Zeic Naomi Ioana','KZ','113720','1970208307432','Str. Observatorului Nr. 93'),
('Tarce Diana Mariana','DP','365983','1971105415851','Str. Dambovitei Nr. 46'),
('Aionitoaie Alexandru - Mihai','GG','712124','1970508054166','Str. Bucuresti Nr. 93'),
('Muntian Razvan Catalin','CJ','141630','1970402203036','Str. Dorobantilor Nr. 31'),
('Daian Dragos Teodor','SX','298765','2940814275551','Str. Cernei Nr. 15'),
('Savan Catalin','SM','360382','1970312359144','Str. Farbicii de Zahar Nr. 138'),
('Moldovan Cristian','VS','190900','2970420432067','Str. Dambovitei Nr. 112'),
('Matei Vladut Ionut','KT','572777','2941220074247','Str. Bucuresti Nr. 128'),
('Chendris Calin - Andrei','KT','969001','2960821225241','Str. Dorobantilor Nr. 71'),
('Pop Patric Virgil','DX','619840','1960421402404','Str. Dorobantilor Nr. 18'),
('Stupinean Andrada Raluca','RT','138627','2940309164312','Str. Cernei Nr. 141'),
('Stan David Mihai','HD','475562','2951215109924','Str. Dambovitei Nr. 125'),
('Neamtu Bogdan - Costel','ZV','344006','2970907466101','Str. Bucuresti Nr. 83'),
('Lepinzan Bogdan Daniel','SV','539113','1960408351875','Str. Farbicii de Zahar Nr. 39'),
('Rad Simion Marius','RR','759394','2960626422196','Str. Dambovitei Nr. 39');
INSERT INTO `assignment3`.`consultation` (`patientId`,`startsAt`,`endsAt`,`doctorId`) VALUES
('1', '2017-05-09 08:15:00', '2017-05-09 09:00:00', '3'),
('1', '2017-05-09 09:00:00', '2017-05-09 09:15:00', '3'),
('2', '2017-05-09 10:30:00', '2017-05-09 11:15:00', '4'),
('2', '2017-05-09 11:15:00', '2017-05-09 11:45:00', '4'),
('3', '2017-05-09 09:15:00', '2017-05-09 09:45:00', '3'),
('3', '2017-05-09 11:45:00', '2017-05-09 12:00:00', '4'),
('4', '2017-05-09 11:45:00', '2017-05-09 12:45:00', '3'),
('4', '2017-05-09 13:00:00', '2017-05-09 13:15:00', '3'),
('5', '2017-05-10 10:15:00', '2017-05-10 10:45:00', '4'),
('5', '2017-05-10 10:15:00', '2017-05-10 11:00:00', '3'),
('6', '2017-05-10 11:00:00', '2017-05-10 11:15:00', '4'),
('6', '2017-05-10 11:15:00', '2017-05-10 12:00:00', '4'),
('7', '2017-05-10 11:15:00', '2017-05-10 12:00:00', '3'),
('7', '2017-05-10 19:15:00', '2017-05-10 19:30:00', '4'),
('8', '2017-05-10 19:15:00', '2017-05-10 19:30:00', '4'),
('8', '2017-05-16 10:15:00', '2017-05-16 11:00:00', '4'),
('9', '2017-05-16 10:15:00', '2017-05-16 11:00:00', '3'),
('9', '2017-05-16 11:15:00', '2017-05-16 11:45:00', '3'),
('10', '2017-05-16 11:45:00', '2017-05-16 12:00:00', '3'),
('10', '2017-05-16 12:15:00', '2017-05-16 12:45:00', '3'),
('11', '2017-05-16 13:15:00', '2017-05-16 13:30:00', '3'),
('11', '2017-05-16 13:30:00', '2017-05-16 14:00:00', '3'),
('12', '2017-05-16 11:15:00', '2017-05-16 12:00:00', '4'),
('12', '2017-05-16 12:00:00', '2017-05-16 12:45:00', '4'),
('13', '2017-05-16 14:00:00', '2017-05-16 14:15:00', '3'),
('13', '2017-05-16 12:45:00', '2017-05-16 13:15:00', '4'),
('14', '2017-05-16 14:15:00', '2017-05-16 15:00:00', '3'),
('14', '2017-05-16 13:15:00', '2017-05-16 13:45:00', '4'),
('15', '2017-05-16 13:45:00', '2017-05-16 14:00:00', '4'),
('15', '2017-05-16 14:15:00', '2017-05-16 14:30:00', '4');
| true
|
fe3f47ae2901187036f3813ae865fbabe876a900
|
SQL
|
IvAvde/mysql-homeworks
|
/mysql hw/hw5.sql
|
UTF-8
| 4,847
| 3.359375
| 3
|
[] |
no_license
|
-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: new_schema1
-- ------------------------------------------------------
-- Server version 8.0.23
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogs`
--
DROP TABLE IF EXISTS `catalogs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `catalogs` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_0900_as_ci DEFAULT NULL COMMENT 'Название раздела',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `unique_name` (`name`(10))
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci COMMENT='Разделы интернет-магазина';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `catalogs`
--
LOCK TABLES `catalogs` WRITE;
/*!40000 ALTER TABLE `catalogs` DISABLE KEYS */;
INSERT INTO `catalogs` VALUES (1,'Процессоры'),(2,'Материнские платы'),(3,'Видеокарты'),(4,'Жесткие диски'),(5,'Оперативная память');
/*!40000 ALTER TABLE `catalogs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `products`
--
DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_0900_as_ci DEFAULT NULL COMMENT 'Название',
`desription` text COLLATE utf8mb4_0900_as_ci COMMENT 'Описание',
`price` decimal(11,2) DEFAULT NULL COMMENT 'Цена',
`catalog_id` int unsigned DEFAULT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `index_of_catalog_id` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci COMMENT='Товарные позиции';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `products`
--
LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_0900_as_ci DEFAULT NULL COMMENT 'Имя покупателя',
`birthday_at` date DEFAULT NULL COMMENT 'Дата рождения',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci COMMENT='Покупатели';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (1,'Геннадий','1990-10-05','2021-04-07 03:59:32','2021-04-07 03:59:32'),(2,'Наталья','1984-11-12','2021-04-07 03:59:32','2021-04-07 03:59:32'),(3,'Александр','1985-05-20','2021-04-07 03:59:32','2021-04-07 03:59:32'),(4,'Сергей','1988-02-14','2021-04-07 03:59:32','2021-04-07 03:59:32'),(5,'Иван','1998-01-12','2021-04-07 03:59:32','2021-04-07 03:59:32'),(6,'Мария','1992-08-29','2021-04-07 03:59:32','2021-04-07 03:59:32');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-04-07 17:35:26
| true
|
49203d09e35e6bb34bb82f410b86e1d7ee0c52b5
|
SQL
|
YoungHan-Jo/db-study
|
/sql/07_집합.sql
|
UTF-8
| 815
| 3.046875
| 3
|
[] |
no_license
|
--집합 연산자
--UNION
SELECT EMPLOYEE_ID, JOB_ID
FROM employees
UNION
SELECT EMPLOYEE_ID, JOB_ID
FROM job_history;
--UNION ALL
SELECT EMPLOYEE_ID, JOB_ID
FROM employees
UNION ALL
SELECT EMPLOYEE_ID, JOB_ID
FROM job_history;
--INTERSECT
SELECT EMPLOYEE_ID, JOB_ID
FROM employees
INTERSECT
SELECT EMPLOYEE_ID, JOB_ID
FROM job_history;
--MINUS
SELECT EMPLOYEE_ID, JOB_ID
FROM employees
MINUS
SELECT EMPLOYEE_ID, JOB_ID
FROM job_history;
--EX
SELECT department_id
FROM employees
UNION
SELECT DEPARTMENT_ID
FROM departments;
--EX
SELECT department_id
FROM employees
UNION ALL
SELECT DEPARTMENT_ID
FROM departments;
--EX
SELECT department_id
FROM employees
INTERSECT
SELECT DEPARTMENT_ID
FROM departments;
--EX
SELECT DEPARTMENT_ID
FROM departments
MINUS
SELECT department_id
FROM employees
| true
|
d97939222203ab6c20ec28f9306e9ca7b7c907a3
|
SQL
|
laurenheff/FebCodeLib
|
/fizzbuzz.sql
|
UTF-8
| 566
| 2.5625
| 3
|
[] |
no_license
|
DECLARE
fizz NUMBER(10);
buzz DECIMAL(10,2);
BEGIN
FOR fizz in 0..99 LOOP
buzz := (fizz + 1);
IF NOT REGEXP_LIKE((buzz / 3 ), '^([0-9])*[.period.]([0-9])*$') THEN
IF NOT REGEXP_LIKE((buzz / 5 ), '^([0-9])*[.period.]([0-9])*$')THEN
dbms_output.put_line('FIZZBUZZ');
ELSE
dbms_output.put_line('FIZZ');
END IF;
ELSE
IF NOT REGEXP_LIKE((buzz / 5 ), '^([0-9])*[.period.]([0-9])*$') THEN
dbms_output.put_line('BUZZ');
ELSE
dbms_output.put_line(buzz);
END IF;
END IF;
END LOOP;
END;
| true
|
a59ed9ea08f78b56390f2480f52779421e18442a
|
SQL
|
camicasii/Mysql-notas
|
/curso.5.sql
|
UTF-8
| 2,599
| 3.953125
| 4
|
[] |
no_license
|
/*Consultas de agrupación o totales. y funciones de agregados*/
/* seleccional la col seccion y la suma de los precios de todos los articulos
agrupandolos por seccion seccion*/
SELECT SECCIÓN, SUM(PRECIO) FROM PRODUCTOS GROUP BY SECCIÓN;
/*ESTA LINEA ARROJA UN ERROR PUESTO NO HAY CAMPO PRECIO EN LA CONSULTA
(NOTA QUE HABLAMOS DE LA CONSULTA Y NO DE LA TABLA)*/
SELECT SECCIÓN, SUM(PRECIO) FROM PRODUCTOS GROUP BY SECCIÓN ORDER BY PRECIO;
/*USANDO UN ASLIAS AS PARA LAS CONSULTA Y ORDENANDO POR EL ALIAS QUE SE
MONTRARA EN LA CONSULTA SI FUNCIONARA */
SELECT SECCIÓN, SUM(PRECIO) AS SUMA_ARTICULOS FROM PRODUCTOS
GROUP BY SECCIÓN ORDER BY SUMA_ARTICULOS;
/* EN ESTE CASO VEMOS LA MISMA INF SOLO QUE AGREGAMOS EN NOMBRE ARTICULO
NOTA QUE AGREGAMOS NOMBRE ARTICULO EN EL BROUP BY, DE LO CONTRARIO DARIA UN ERROR DE CONSULTA*/
SELECT SECCIÓN, NOMBREARTÍCULO , SUM(PRECIO) AS SUMA_ARTICULOS FROM PRODUCTOS
GROUP BY SECCIÓN, NOMBREARTÍCULO ORDER BY SUMA_ARTICULOS;
/* NOTA QUE EN ESTE CASO ESTAMOS UBICANDO LA MEDIA DE LOS PRECION
DE LA SECCION DEPORTES Y SERAMICA NOTE QUE SE USA EL COMANDO HAVING EN VES DE WHERE PARA
FILTRAR LA BUSQUEDA
*/
SELECT SECCIÓN, AVG(PRECIO) AS MEDIA_ARTICULOS FROM PRODUCTOS
GROUP BY SECCIÓN HAVING SECCIÓN='DEPORTES' OR SECCIÓN='CERÁMICA';
/* EN ESTE CASO ORDENAMOS LA COL MEDIA_ARTICULOS */
SELECT SECCIÓN, AVG(PRECIO) AS MEDIA_ARTICULOS FROM PRODUCTOS
GROUP BY SECCIÓN HAVING SECCIÓN='DEPORTES' OR SECCIÓN='CONFECCIÓN'
ORDER BY MEDIA_ARTICULOS;
/* EN ESTE CASO CONTAMOS CUANTOS CLIENTES TENEMOS POR POBLACION*/
SELECT POBLACIÓN, COUNT(CÓDIGOCLIENTE) AS N_CLIENTES FROM CLIENTES
GROUP BY POBLACIÓN;
/* UBICAMOS LA SECCION QUE TENGA EL PRECIO MAXIMO DE VENTA*/
SELECT SECCIÓN, MAX(PRECIO) AS PRECIO_MAX FROM PRODUCTOS WHERE
SECCIÓN='CONFECCIÒN' GROUP BY SECCIÓN;
/* LA SIGUIENTE LINEA DA ERROR PORQUE LA CLAPSULA WHERE DEBE IR ANTES DE GROUP BY*/
/*
SELECT SECCIÓN, MAX(PRECIO) AS PRECIO_MAX FROM PRODUCTOS
GROUP BY SECCIÓN WHERE SECCIÓN='CONFECCIÓN';
*/
/* BUSCAMOS EN ARTICULO CON EL PRECIO MAXIMO DE LA SECCION CONFECCION Y SOLO MOSTRAMOS
UN ARTICULO LIMITANDO LA CONSULTA A 1*/
SELECT SECCIÓN, NOMBREARTÍCULO, MAX(PRECIO) AS PRECIO_MAX FROM PRODUCTOS WHERE
SECCIÓN='CONFECCIÓN' GROUP BY SECCIÓN,NOMBREARTÍCULO/* LIMIT 1;*/;
/* ESTA LINEA ESPECIFICAMOS MEJOR LA CONSULTA PIDIENDO QUE ORDENE LOS PRODUCTOS
Y ME MUESTRE SOLO EL MAX*/
SELECT SECCIÓN, NOMBREARTÍCULO, MAX(PRECIO) AS PRECIO_MAX FROM
PRODUCTOS WHERE SECCIÓN='CONFECCIÓN' GROUP BY SECCIÓN,NOMBREARTÍCULO
ORDER BY PRECIO_MAX DESC /*LIMIT 1*/;
| true
|
cf4bbbcd2c54e208aa6c6cbc49b5c16990a694ea
|
SQL
|
blee025/SG-Summatives
|
/SummativeSums/SuperheroSightingsMastery/SuperheroSightingsDB.sql
|
UTF-8
| 3,648
| 3.609375
| 4
|
[] |
no_license
|
DROP DATABASE IF EXISTS SuperheroSightingsDB;
CREATE DATABASE SuperheroSightingsDB;
USE SuperheroSightingsDB;
Create table Powers (
Id int Primary Key auto_increment,
`Name` varchar(30) not null
);
Create table Supes (
Id int Primary Key auto_increment,
`Name` varchar(30) not null,
`Description` varchar(150) not null,
`PowerId` int not null,
foreign key fk_Super_Power (PowerId)
references Powers(Id)
);
Create table Organizations (
Id int Primary Key auto_increment,
`Name` varchar(30) not null,
`Description` varchar(150) not null,
Address varchar(60) not null
);
Create table SuperOrganizations (
`OrganizationId` int,
`SupeId` int,
Primary key (OrganizationId, SupeId),
foreign key fk_SuperOrganizations_Organization (OrganizationId)
references Organizations(Id),
foreign key fk_SuperOrganizations_Supe (SupeId)
references Supes(Id)
);
Create table Locations (
Id int Primary Key auto_increment,
`Name` varchar(30) not null,
Address varchar(60) not null,
Latitude Decimal(9,6) not null,
Longitude Decimal(9,6) not null
);
Create table Sightings (
Id int Primary Key auto_increment,
`Date` date not null,
`LocationId` int not null,
`SupeId` int not null,
foreign key fk_Sighting_Location (LocationId)
references Locations(Id),
foreign key fk_Sightings_Supe (SupeId)
references Supes(Id)
);
Insert into Powers (Id, `Name`)
Values
('1','Fire'),
('2','Water'),
('3','Earth'),
('4','Air'),
('5','Magic');
Insert into Supes (Id, `Name`, `Description`, PowerId)
Values
('1','Phantom','Super cool','5'),
('2','Amethyst','Bad villian','4'),
('3','Cybernetic','Tech dude','2'),
('4','Mistoad','Literal Toad','3'),
('5','Transfreezer','Really cold','2'),
('6','Enchanter','Freaky magic','5'),
('7','Dynafire','So hot','1'),
('8','Luminous','Very bright','1'),
('9','Spectral','Unknown','5'),
('10','Obsidian','Hard material','3');
Insert into Organizations (Id, `Name`, `Description`, Address)
Values
('1','Outcasts','Odd ones','377 Border Road'),
('2','Venomous ','Nasty villians','12 MeadowBrook Street'),
('3','Angels','Top heroes','2224 Harvard Court'),
('4','Mutants','Weird animals','8 Cardinal Lane');
Insert into SuperOrganizations (`OrganizationId`, SupeId)
Values
('1','2'),
('1','4'),
('1','5'),
('1','9'),
('2','2'),
('2','7'),
('2','10'),
('3','1'),
('3','3'),
('3','6'),
('3','8'),
('3','9'),
('4','4');
Insert into Locations (Id, `Name`, Address, Latitude, Longitude)
Values
('1','Local Lamp Post','1 Clark Ave.','-26.640281','83.469807'),
('2','Clear Blue Pond','2 Creek Street','-8.386259','-70.48434'),
('3','darkest alley','3 Monroe Road','23.97048','110.648223'),
('4','Sally Statue','4 Selby Lane','13.487871','58.255566'),
('5','Crashed Stoplight','5 Overlook Drive','-40.381718','-11.677544'),
('6','Blue House','6 Coffee Lane','4.174554','-127.41775'),
('7','Light Laboratory','7 Woodside Street','55.792117','151.477972'),
('8','Zoo','8 Charles Ave.','13.978816','53.981198'),
('9','Joes Store','9 Pine Street','89.999997','-129.662608'),
('10','James Hospital','10 Elmwood Dr.','81.338119','163.794405');
Insert into Sightings (Id, `Date`, LocationId, SupeId)
Values
('1','2019-01-04','3','2'),
('2','2019-01-26','7','4'),
('3','2019-02-14','3','9'),
('4','2019-03-18','9','4'),
('5','2019-03-29','5','5'),
('6','2019-05-09','1','1'),
('7','2019-06-13','4','3'),
('8','2019-06-21','6','6'),
('9','2019-07-18','8','7'),
('10','2019-08-12','8','3');
| true
|
40ee4cf0097b89c62ce6c2d073487c7c811a23d4
|
SQL
|
baijiupeng/PropertyManagementSystem
|
/database/property_management_system_course.sql
|
UTF-8
| 4,553
| 3.359375
| 3
|
[] |
no_license
|
/*
Navicat Premium Data Transfer
Source Server : LocalMySQL
Source Server Type : MySQL
Source Server Version : 80014
Source Host : localhost:3306
Source Schema : property_management_system_course
Target Server Type : MySQL
Target Server Version : 80014
File Encoding : 65001
Date: 13/05/2019 22:37:55
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for house
-- ----------------------------
DROP TABLE IF EXISTS `house`;
CREATE TABLE `house` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`area` varchar(255) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`amount` float unsigned DEFAULT NULL,
`billstate` varchar(255) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_house_user` (`uid`),
CONSTRAINT `fk_house_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for pet
-- ----------------------------
DROP TABLE IF EXISTS `pet`;
CREATE TABLE `pet` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deadline` date DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_pet_user` (`uid`),
CONSTRAINT `fk_pet_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for postinfo
-- ----------------------------
DROP TABLE IF EXISTS `postinfo`;
CREATE TABLE `postinfo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(255) DEFAULT NULL,
`message` varchar(255) DEFAULT NULL,
`date` datetime DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_info_user` (`uid`),
CONSTRAINT `fk_info_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for resource
-- ----------------------------
DROP TABLE IF EXISTS `resource`;
CREATE TABLE `resource` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(255) DEFAULT NULL,
`cost` float DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`deadline` date DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_resource_user` (`uid`),
CONSTRAINT `fk_resource_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for review
-- ----------------------------
DROP TABLE IF EXISTS `review`;
CREATE TABLE `review` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` varchar(255) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
`infoid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_review_user` (`uid`),
KEY `fk_review_info` (`infoid`),
CONSTRAINT `fk_review_info` FOREIGN KEY (`infoid`) REFERENCES `postinfo` (`id`),
CONSTRAINT `fk_review_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for staff
-- ----------------------------
DROP TABLE IF EXISTS `staff`;
CREATE TABLE `staff` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`phone` int(11) DEFAULT NULL,
`job` varchar(255) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for support
-- ----------------------------
DROP TABLE IF EXISTS `support`;
CREATE TABLE `support` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(255) DEFAULT NULL,
`detail` varchar(255) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`feedback` varchar(500) DEFAULT NULL,
`staffid` int(11) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_service_user` (`uid`),
KEY `fk_service_staff` (`staffid`),
CONSTRAINT `fk_service_staff` FOREIGN KEY (`staffid`) REFERENCES `staff` (`id`),
CONSTRAINT `fk_service_user` FOREIGN KEY (`uid`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`gender` varchar(255) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
| true
|
1ae7bd267a6f248c1f04457c44d53f0cdb9d75e9
|
SQL
|
beatrizsnichelotto/curso-spring-rest-AlgaWorks
|
/curso-spring -rest (AlgaWorks)/src/main/resources/db/migration/V004_cria-tabela-comentario.sql
|
UTF-8
| 327
| 2.96875
| 3
|
[] |
no_license
|
create table comentario (
id bigint not null auto_increment,
ordem_servico_id bigint not null,
descricao text not null,
data_envio datetime not null,
primary key (id)
ORDEM_SERVICO_COMENTARIOS
);
alter table comentario and constraint fk_comentario_ordem_servico
foreign key (ordem_servico_id) references ordem_servico (id);
| true
|
e10f95d04d0cbdb93abfaf601c97e6d9dab7b5e8
|
SQL
|
Sinosaurus/example
|
/php/myPhp/test/day6/one.sql
|
UTF-8
| 1,064
| 3.609375
| 4
|
[] |
no_license
|
#创建表格
create table jd_goods (
goods_id int primary key auto_increment,
goods_name varchar(30) not null unique key,
price decimal(7, 2) not null default 300,
cat_name varchar(20),
sales int not null default 0,
is_post_free tinyint not null default 1 comment '1包邮 0不包邮',
pics varchar(200)
);
insert into jd_goods values
(null, '凌美', 123.5, '笔', 72, 1, '1.jpg'),
(null, '施耐德', 50.5, '笔', 200, 1, '2.jpg'),
(null, '百乐', 100.5, '笔', 130, 0, '13.jpg'),
(null, '英雄', 333.5, '笔', 1200, 1, '4.jpg'),
(null, '派克', 500.5, '笔', 20, 0, '5.jpg'),
(null, '百乐墨水', 30.5, '墨水', 120, 1, '6.jpg'),
(null, '鲶鱼', 80, '墨水', 20, 1, '7.jpg'),
(null, '英雄墨水', 16.5, '墨水', 5000, 1, '8.jpg'),
(null, '墨水1', 50, '墨水', 710, 0, '9.jpg');
#分组
select goods_name, price, sales from jd_goods /*drop by */cat_name;//只会显示每组中第一个
select goods_name, price, sales , count(*) from jd_goods group by cat_name;
#分页
select * from jd_goods limit 3,3;
| true
|
6699fd5178f912f95ed05ad410fa5ef4a67fc957
|
SQL
|
krimmkr/MIPT-Programming
|
/1 Sem/DataBases/SQL/047.SQL
|
UTF-8
| 312
| 3.703125
| 4
|
[] |
no_license
|
SELECT x ,maker ,model FROM
(SELECT ROW_NUMBER() OVER(ORDER BY y ,model) AS x ,y ,maker ,model FROM
(SELECT * FROM
(SELECT ROW_NUMBER() OVER(ORDER BY c1 DESC,maker) AS y ,maker AS maker1,c1 FROM
(SELECT maker,COUNT(model) c1 FROM Product GROUP BY maker)t )q
JOIN Product
ON maker1=Product.maker)o)p
| true
|
43cdf5e62bacf70889eda8d457e3eea1d81a9214
|
SQL
|
VI-Suji/Athena21
|
/athena.sql
|
UTF-8
| 6,322
| 2.984375
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3308
-- Generation Time: Apr 17, 2021 at 06:05 PM
-- Server version: 8.0.18
-- PHP Version: 7.3.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `athena`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
DROP TABLE IF EXISTS `admin`;
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`name` varchar(30) NOT NULL,
`password` varchar(60) NOT NULL,
`category` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `email`, `name`, `password`, `category`) VALUES
(1, 'organizer1', 'Muiz', '$2b$08$Dpi9FalNeP5FmxB5dlQx6uV1svhOBqMbGjFgUFz5c1PNSvGqIJ636', 'organizer'),
(2, 'superadmin1', 'Vishnu', '$2b$08$Dpi9FalNeP5FmxB5dlQx6uV1svhOBqMbGjFgUFz5c1PNSvGqIJ636', 'superadmin'),
(3, 'finance1', 'Shwetha', '$2b$08$Dpi9FalNeP5FmxB5dlQx6uV1svhOBqMbGjFgUFz5c1PNSvGqIJ636', 'finhead');
-- --------------------------------------------------------
--
-- Table structure for table `events`
--
DROP TABLE IF EXISTS `events`;
CREATE TABLE IF NOT EXISTS `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) NOT NULL,
`date` varchar(30) NOT NULL,
`description` varchar(1000) NOT NULL,
`eventamount` int(30) NOT NULL,
`others` varchar(1000) DEFAULT NULL,
`flag` varchar(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `events`
--
INSERT INTO `events` (`id`, `name`, `date`, `description`, `eventamount`, `others`, `flag`) VALUES
(1, 'event 1', '213213', '3232', 1000, 'eerfer', '1');
-- --------------------------------------------------------
--
-- Table structure for table `notify`
--
DROP TABLE IF EXISTS `notify`;
CREATE TABLE IF NOT EXISTS `notify` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`error_name` varchar(100) NOT NULL,
`category` varchar(20) NOT NULL,
`description` varchar(100) NOT NULL,
`image` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- --------------------------------------------------------
--
-- Table structure for table `registration`
--
DROP TABLE IF EXISTS `registration`;
CREATE TABLE IF NOT EXISTS `registration` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`eventName1` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`eventName2` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`eventName3` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`isISTE` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`ISTEregno` int(30) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `registration`
--
INSERT INTO `registration` (`id`, `name`, `email`, `eventName1`, `eventName2`, `eventName3`, `isISTE`, `ISTEregno`) VALUES
(1, 'muiz', 'zzzzz', 'event 3', NULL, NULL, NULL, 0),
(2, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(3, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(4, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(5, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(6, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(7, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(8, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(9, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(10, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(11, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(12, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(13, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(14, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(15, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(16, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(17, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(18, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(19, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(20, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(21, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(22, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(23, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(24, 'muiz', 'zzzzz', 'event 2', NULL, NULL, NULL, 0),
(25, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(26, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(27, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(28, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(29, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(30, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(31, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(32, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(33, 'muiz', 'zzzzz', 'event 1', NULL, NULL, NULL, 0),
(34, 'muiz', 'zzzzz', 'event 1', 'event 1', 'event 1', NULL, 0),
(35, 'muiz', 'zzzzz', 'event 1', 'event 1', 'event 1', NULL, 0);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(30) NOT NULL,
`name` varchar(40) NOT NULL,
`password` varchar(300) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `email`, `name`, `password`) VALUES
(1, 'zzzzz', 'muiz', '$2b$08$Dpi9FalNeP5FmxB5dlQx6uV1svhOBqMbGjFgUFz5c1PNSvGqIJ636'),
(2, 'zzzz', 'muiz', '$2b$08$XwLd5tRYD7PuWiHZ6NOT6uOTdb94m0PsRakpK8YMik5a/0JHT4EUi');
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
ae3dfe684e73f1bbdd75892a8b61653254f858f1
|
SQL
|
ahmetbozaci/SQL
|
/2-select_world.sql
|
UTF-8
| 1,091
| 3.84375
| 4
|
[] |
no_license
|
-- 2
SELECT name
FROM world
WHERE population > 200000000;
-- 3
SELECT name, GDP / population
FROM world
WHERE population > 200000000;
-- 4
SELECT name, population / 1000000
FROM world
WHERE continent = 'South America';
-- 5
SELECT name, population
FROM world
WHERE name IN ('France', 'Germany', 'Italy');
-- 6
SELECT name
FROM world
WHERE name LIKE ('%United%');
-- 7
SELECT name, population, area
FROM world
WHERE area > 3000000 OR population > 250000000;
-- 8
SELECT name, population, area
FROM world
WHERE area > 3000000 XOR population > 250000000;
-- 9
SELECT name, ROUND(population/1000000,2), ROUND(GDP/1000000000,2)
FROM world
WHERE continent = 'South America';
-- 10
SELECT name, ROUND(GDP/ population,-3)
FROM world
WHERE GDP > 1000000000000;
-- 11
SELECT name, capital
FROM world
WHERE LENGTH(name) = LENGTH(capital);
-- 12
SELECT name, capital
FROM world
WHERE LEFT(name,1) = LEFT(capital,1) AND name != capital;
-- 13
SELECT name
FROM world
WHERE name LIKE '%a%'
AND name LIKE '%e%'
AND name LIKE '%i%'
AND name LIKE '%o%'
AND name LIKE '%u%'
AND name NOT LIKE '% %';
| true
|
f9b930097fbaab2154a8180dd12ce981c80f5471
|
SQL
|
silence-do-good/stress-test-Postgres-and-MySQL
|
/dump/high/day15/select0925.sql
|
UTF-8
| 178
| 2.671875
| 3
|
[] |
no_license
|
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-14T09:25:00Z' AND timestamp<'2017-11-15T09:25:00Z' AND temperature>=42 AND temperature<=69
| true
|
5384ffcf16d70af57f11d1165e2a0777220d471a
|
SQL
|
jenguin777/bamazon
|
/bamazon.sql
|
UTF-8
| 7,279
| 3.546875
| 4
|
[
"MIT"
] |
permissive
|
-- DDL for bamazonCustomer.js and bamazonManager.js
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Grape777!'
drop database if exists bamazon;
create database bamazon;
use bamazon;
CREATE TABLE products (
item_id INT NOT NULL AUTO_INCREMENT,
product_name VARCHAR(255) NOT NULL,
department_name VARCHAR(255) NOT NULL,
price Decimal(19,4) default 0,
stock_quantity INT default 0,
PRIMARY KEY (item_id)
);
-- Create products
insert into products (product_name, department_name, price, stock_quantity)
values ("Schwinn Bike", "Sports and Outdoors", 400.00, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("Daggar Kayak", "Sports and Outdoors", 999.00, 5);
insert into products (product_name, department_name, price, stock_quantity)
values ("Aquabound Kayak Paddle", "Sports and Outdoors", 135.00, 5);
insert into products (product_name, department_name, price, stock_quantity)
values ("JavaScript: The Good Parts", "Books", 19.65, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("JavaScript: The Definitive Guide: Activate Your Web Pages (Definitive Guides)", "Books", 19.65, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("Adjustable Monitor Stand", "Computers", 19.65, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("Fire TV Stick", "Electronics", 39.99, 15);
insert into products (product_name, department_name, price, stock_quantity)
values ("Fire TV Stick", "Electronics", 39.99, 15);
insert into products (product_name, department_name, price, stock_quantity)
values ("3 Qt Stainless Saucepan", "Housewares", 39.99, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("20 piece Stainless Steel Flatware", "Housewares", 19.99, 10);
insert into products (product_name, department_name, price, stock_quantity)
values ("32 inch HDTV", "Electronics", 199.99, 15);
-- additional helpful queries
-- use bamazon database
use bamazon;
select * from products;
select * FROM products order by department_name asc, product_name asc;
-- show item_id, product_name, department_name, price for all products, order by department
select item_id, product_name, department_name, round(price, 2) as price FROM products order by department_name asc;
-- show item_id, product_name, department_name, price, stock_quantity for all products, order by department
select item_id, product_name, department_name, round(price, 2) as price, stock_quantity FROM products order by department_name asc;
-- show item_id, product_name, stock_quantity for all products, order by department
select item_id, product_name, stock_quantity FROM products order by department_name asc;
-- show item_id, product_name, stock_quantity for all products, order by product_name
select item_id, product_name, stock_quantity FROM products order by product_name asc;
-- show specific product (by item_id)
select item_id, product_name, department_name, round(price, 2) as price, stock_quantity FROM products where item_id = 10;
-- UPDATE products SET stock_quantity = 11 WHERE item_id = 1;
-- delete from products where item_id = 14;
-- DDL for departments table, used by bamazonSupervisor.js
use bamazon;
CREATE TABLE departments (
department_id INT NOT NULL AUTO_INCREMENT,
department_name VARCHAR(255) NOT NULL,
overhead_costs Decimal(19,4) default 0,
PRIMARY KEY (department_id)
);
-- add product_sales column to products table
-- alter table products
-- add column product_sales Decimal(19,4) default 0;
-- Create departments
insert into departments (department_name, overhead_costs)
values ("Sports and Outdoors", 5000.00);
insert into departments (department_name, overhead_costs)
values ("Books", 3000.00);
insert into departments (department_name, overhead_costs)
values ("Computers", 10000.00);
insert into departments (department_name, overhead_costs)
values ("Electronics", 8000.00);
insert into departments (department_name, overhead_costs)
values ("Housewares", 6000.00);
-- additional helpful queries
select * from departments order by department_name asc;
-- show item_id, product_name, department_name, price, stock_quantity, product_sales for all products, order by department
select item_id, product_name, department_name, round(price, 2) as price, stock_quantity, product_sales FROM products where item_id = 12;
-- show distinct department_names in product table
Select distinct department_name from products;
-- show distinct department_names in departments table
Select distinct department_name from departments;
-- show product_sales grouped by department
Select department_name, sum(product_sales) from products
group by department_name;
Select * from departments;
-- Update departments set overhead_costs = 200 where department_id = 6;
-- View Product Sales By Department Query
select departments.department_id, departments.department_name, departments.overhead_costs, sum(products.product_sales) as product_sales_total, sum(products.product_sales) - departments.overhead_costs as total_profit
FROM departments
inner join products
on TRIM(departments.department_name) = TRIM(products.department_name)
where products.department_name = departments.department_name
group by departments.department_name
order by departments.department_name asc;
-- View Product Sales By Department Query on one line - too restrictive, doesn't handle newly added departments that have no products because Manager hasn't added them yet
select departments.department_id, departments.department_name, departments.overhead_costs, sum(products.product_sales) as product_sales_total, sum(products.product_sales) - departments.overhead_costs as total_profit FROM departments inner join products on TRIM(departments.department_name) = TRIM(products.department_name) where products.department_name = departments.department_name group by departments.department_name order by departments.department_name asc;
-- Equivalent of full join, returns 11 rows, Sports and Outdoors duplicated, I know how to fix this in Oracle but the Oracle SQL
-- fix (4 table aliases, T2.department_name != T4.department name) doesn't work in mySQL.
-- error is: Error Code: 1054. Unknown column 'T2.department_name' in 'on clause' 0.000 sec
select departments.department_id, departments.department_name, departments.overhead_costs,
sum(products.product_sales) as product_sales_total, sum(products.product_sales) - departments.overhead_costs as total_profit
FROM products
left join departments on TRIM(departments.department_name) = TRIM(products.department_name)
UNION ALL select departments.department_id, departments.department_name, departments.overhead_costs,
sum(products.product_sales) as product_sales_total, sum(products.product_sales) - departments.overhead_costs as total_profit
FROM products right join departments
on TRIM(departments.department_name) = TRIM(products.department_name)
group by departments.department_name;
--query for making the department list dynamic in Manager addNewProduct() after addeding Supervisor addNewDepartment
select distinct(department_name) FROM departments order by department_name asc;
| true
|
05f50a174f8bcdd280e5b1e1a066bebf858613e4
|
SQL
|
AirDnD/CustomerReview
|
/database/PSQL/postgreSchema.sql
|
UTF-8
| 1,360
| 3.890625
| 4
|
[] |
no_license
|
-- \l reviews_db
CREATE TABLE users (
id int NOT NULL,
name text,
photo text,
PRIMARY KEY (id)
);
CREATE TABLE listings (
id int NOT NULL,
name text,
PRIMARY KEY (id)
);
CREATE TABLE reviews (
id SERIAL NOT NULL,
listing_id int NOT NULL,
user_id int NOT NULL,
accuracy DECIMAL(2,1) NOT NULL,
communication DECIMAL(2,1) NOT NULL,
cleanliness DECIMAL(2,1) NOT NULL,
location DECIMAL(2,1) NOT NULL,
check_in DECIMAL(2,1) NOT NULL,
_value DECIMAL(2,1) NOT NULL,
_date date NOT NULL,
content text,
PRIMARY KEY (id),
FOREIGN KEY (listing_id) REFERENCES listings(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
--postgres -D /usr/local/var/postgres
-- \copy reviews FROM ReviewData.csv DELIMITER ',' CSV
-- psql DATABASE NAME
-- \l - list db
-- \c use database
-- \d - list tables
-- \i postgreSchema.sql - use schema
-- \dt - show tables
-- \q
-- pgbench -i dbname
-- pgbench -c 1 <databasename> -f <sqlfile>
-- pg stats statement sl
-- export table
-- \COPY (select * FROM users INNER JOIN reviews ON users.id = reviews.user_id ORDER BY reviews.id ASC) TO 'combine.csv' (format CSV);
-- explain analyze select users.name, users.photo, reviews._date, reviews.content FROM users JOIN reviews on reviews.user_id = users.id where reviews.listing_id = 4;
-- // above will display where the source of latency is
| true
|
e14db922b623e5b25d2dd2f38100be426c5980b3
|
SQL
|
MauricioMichels/UC3M
|
/ComputacionWeb/Projeto Final/splittex/tables.sql
|
UTF-8
| 2,031
| 3.75
| 4
|
[] |
no_license
|
DROP TABLE IF EXISTS Invitations;
DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS GroupUser;
DROP TABLE IF EXISTS Groups;
DROP TABLE IF EXISTS Users;
CREATE TABLE Users (
id INT NOT NULL auto_increment,
userName VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
PRIMARY KEY(id)
)ENGINE=INNODB;
CREATE TABLE Groups (
id INT NOT NULL auto_increment,
groupName VARCHAR(255) NOT NULL,
creator INT NOT NULL,
creationDate DATE NOT NULL,
lastChangeDate DATE NOT NULL,
actualState INT NOT NULL,
PRIMARY KEY(id),
CONSTRAINT FOREIGN KEY (creator) REFERENCES Users(id)
)ENGINE=INNODB; /*actualState: 1-inactive 2-active 3-closed*/
CREATE TABLE GroupUser (
userId INT NOT NULL,
groupId INT NOT NULL,
state INT NOT NULL,
balance DOUBLE NOT NULL,
PRIMARY KEY(userId,groupId),
CONSTRAINT FOREIGN KEY (userId) REFERENCES Users(id),
CONSTRAINT FOREIGN KEY (groupId) REFERENCES Groups(id)
)ENGINE=INNODB; /*state: 1-invited 2-accepted 3-rejected*/
CREATE TABLE Transactions (
id INT NOT NULL auto_increment,
subject VARCHAR(255) NOT NULL,
moment DATE NOT NULL,
groupId INT NOT NULL,
payerUser INT NOT NULL,
recieverUser INT NOT NULL,
amount DOUBLE NOT NULL,
PRIMARY KEY(id),
CONSTRAINT FOREIGN KEY (groupId) REFERENCES Groups(id),
CONSTRAINT FOREIGN KEY (payerUser) REFERENCES Users(id),
CONSTRAINT FOREIGN KEY (recieverUser) REFERENCES Users(id)
)ENGINE=INNODB;
CREATE TABLE Invitations (
userId INT NOT NULL,
groupId INT NOT NULL,
responseState VARCHAR(255) NOT NULL,
invitationDate DATE NOT NULL,
responseDate DATE,
PRIMARY KEY(userId,groupId),
CONSTRAINT FOREIGN KEY (userId) REFERENCES Users(id),
CONSTRAINT FOREIGN KEY (groupId) REFERENCES Groups(id)
)ENGINE=INNODB; /*responseState: 1-noResponse 2-accepted 3-rejected*/
| true
|
b306c2bfbdc48a342f5715075b977ca1cee1ddd8
|
SQL
|
wilnelmpls/CDM
|
/CDM/CDM/Tables/ContactBridge.sql
|
UTF-8
| 903
| 3.171875
| 3
|
[] |
no_license
|
CREATE TABLE [CDM].[ContactBridge] (
[ContactBridgeID] INT IDENTITY (1, 1) NOT NULL,
[CustomerAccountID] INT NULL,
[ContactID] INT NULL,
[SourceSystemID] INT NULL,
[Status] BIT NULL,
[ContactPurpose] VARCHAR (35) NULL,
[IsPrimaryByPurpose] BIT NULL,
[CreateDTS] DATETIME NULL,
[UpdateDTS] DATETIME NULL,
PRIMARY KEY CLUSTERED ([ContactBridgeID] ASC),
CONSTRAINT [FK_ContactBridge_To_Contact] FOREIGN KEY ([ContactID]) REFERENCES [CDM].[Contacts] ([ContactID]),
CONSTRAINT [FK_ContactBridge_To_CustomerAccount] FOREIGN KEY ([CustomerAccountID]) REFERENCES [CDM].[CustomerAccounts] ([CustomerAccountID]),
CONSTRAINT [FK_ContactBridge_To_SourceSystem] FOREIGN KEY ([SourceSystemID]) REFERENCES [CDM].[SourceSystem] ([SourceSystemID])
);
| true
|
e24228433173e50e1c72d0c7ad83d0d289a1e6f9
|
SQL
|
SDC-Haskell/QuestionsandAnswers
|
/Schema.sql
|
UTF-8
| 1,109
| 3.671875
| 4
|
[
"Unlicense"
] |
permissive
|
DROP DATABASE IF EXISTS qanda;
CREATE DATABASE qanda;
\c qanda;
CREATE TABLE questions (
id serial PRIMARY KEY,
product_id int NOT NULL,
body varchar NOT NULL,
date_written DATE,
asker_name varchar,
asker_email varchar,
reported int,
helpful int
);
CREATE TABLE answers (
id serial PRIMARY KEY,
question_id int,
FOREIGN KEY (question_id) REFERENCES questions(id) ON DELETE cascade,
body varchar NOT NULL,
date_written DATE,
answerer_name varchar,
answerer_email varchar,
reported int,
helpful int
);
CREATE TABLE answerphotos (
id serial PRIMARY KEY,
answer_id int,
FOREIGN KEY (answer_id) REFERENCES answers(id) ON DELETE cascade,
url varchar NOT NULL
);
COPY questions FROM '/home/n/Desktop/questions.csv' DELIMITER ',' CSV HEADER;
COPY answers FROM '/home/n/Desktop/answers.csv' DELIMITER ',' CSV HEADER;
COPY answerphotos FROM '/home/n/Desktop/answers_photos.csv' DELIMITER ',' CSV HEADER;
Create index answer_id_idx on answerphotos (answer_id);
create index question_id_idx on answers (question_id);
create index product_id_idx on questions (product_id);
| true
|
f6006d8908cbba6ab0c9bbb043f0a6b2367f759e
|
SQL
|
VijayEluri/user-manager-example
|
/src/main/resources/db/init_db.sql
|
UTF-8
| 260
| 3.015625
| 3
|
[] |
no_license
|
CREATE DATABASE IF NOT EXISTS finance;
USE finance;
CREATE TABLE IF NOT EXISTS users (
id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
login VARCHAR(30),
name VARCHAR(30),
email VARCHAR(30),
phone VARCHAR(30),
INDEX(name)
) engine=InnoDB;
| true
|
2888589d5342d9e5df6f6a970dc556bacb3a52f4
|
SQL
|
PlamenaMiteva/Databases
|
/Databese Systems Overview Homework/10. SQL Language.sql
|
UTF-8
| 715
| 3.265625
| 3
|
[] |
no_license
|
Problem 10. SQL Language
SQL is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS),
or for stream processing in a relational data stream management system (RDSMS).
Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language.
The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control.
Although SQL is often described as, and to a great extent is, a declarative language, it also includes procedural elements.
SQL query example
SELECT *
FROM Stident
WHERE grade > 5
ORDER BY name;
| true
|
072d624da38eeb0273aa3c8d2ddd16032adccb68
|
SQL
|
4uqills/Lab2c
|
/pessdb .sql
|
UTF-8
| 5,463
| 3.078125
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 04, 2021 at 05:04 PM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `pessdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `dispatch`
--
CREATE TABLE `dispatch` (
`incidentId` int(11) NOT NULL,
`patrolcarId` varchar(10) NOT NULL,
`timeDispatched` datetime NOT NULL,
`timeArrived` datetime DEFAULT NULL,
`timeCompleted` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `incident`
--
CREATE TABLE `incident` (
`incidentid` int(11) NOT NULL,
`callername` varchar(30) NOT NULL,
`phonenumber` varchar(10) NOT NULL,
`incidenttypeid` varchar(3) NOT NULL,
`incidentlocation` varchar(50) NOT NULL,
`incidentdesc` varchar(100) NOT NULL,
`incidentstatusid` varchar(1) NOT NULL,
`timecalled` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `incident`
--
INSERT INTO `incident` (`incidentid`, `callername`, `phonenumber`, `incidenttypeid`, `incidentlocation`, `incidentdesc`, `incidentstatusid`, `timecalled`) VALUES
(43, 'aqilah', '87255661', '070', 'singapore', ' \r\n swfdegfrh', '2', '2021-11-03 15:56:21'),
(42, 'aqilah', '87255661', '070', 'singapore', ' \r\n fffff', '2', '2021-11-03 15:56:06'),
(44, 'aqilah', '87255661', '070', 'singapore', ' \r\ndswefsrgt', '2', '2021-11-03 15:56:46'),
(45, 'aqilah', '87255661', '070', 'singapore', ' \r\n dsdff', '2', '2021-11-03 15:57:14'),
(46, 'aqilah', '87255661', '070', 'singapore', ' \r\n wAESRDT', '2', '2021-11-03 15:57:34'),
(47, 'aqilah', '97650272', '070', 'singapore', '\r\n wfae', '2', '2021-11-03 15:57:57'),
(48, 'aqilah', '87255661', '070', 'singapore', ' \r\n dwe', '2', '2021-11-03 15:58:22'),
(49, 'aqilah', '87255661', '070', 'singapore', ' \r\n xsdc', '2', '2021-11-03 15:58:42'),
(50, 'aqilah', '87255661', '070', 'singapore', 'cd c', '2', '2021-11-03 15:59:00');
-- --------------------------------------------------------
--
-- Table structure for table `incidenttype`
--
CREATE TABLE `incidenttype` (
`incidenttypeid` varchar(3) NOT NULL,
`incidenttypedesc` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `incidenttype`
--
INSERT INTO `incidenttype` (`incidenttypeid`, `incidenttypedesc`) VALUES
('070', 'Loan Shark'),
('010', 'Fire'),
('020', 'Riot'),
('030', 'Burglary'),
('040', 'Domestic Violent'),
('050', 'Fallen Tree'),
('060', 'Traffic Accident'),
('999', 'Others');
-- --------------------------------------------------------
--
-- Table structure for table `incident_status`
--
CREATE TABLE `incident_status` (
`statusId` varchar(1) NOT NULL,
`statusDesc` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `incident_status`
--
INSERT INTO `incident_status` (`statusId`, `statusDesc`) VALUES
('1', 'Pending'),
('2', 'Dispatched'),
('3', 'Completed'),
('4', 'Duplicate');
-- --------------------------------------------------------
--
-- Table structure for table `patrolcar`
--
CREATE TABLE `patrolcar` (
`patrolcarId` varchar(10) NOT NULL,
`patrolcarStatusId` varchar(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `patrolcar`
--
INSERT INTO `patrolcar` (`patrolcarId`, `patrolcarStatusId`) VALUES
('QX4444D', '3'),
('QX3333C', '3'),
('QX2222B', '1'),
('QX1111A', '1');
-- --------------------------------------------------------
--
-- Table structure for table `patrolcar_status`
--
CREATE TABLE `patrolcar_status` (
`statusId` varchar(1) NOT NULL,
`statusDesc` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `patrolcar_status`
--
INSERT INTO `patrolcar_status` (`statusId`, `statusDesc`) VALUES
('1', 'Dispatched'),
('2', 'Patrol'),
('3', 'Free'),
('4', 'Arrived');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `dispatch`
--
ALTER TABLE `dispatch`
ADD PRIMARY KEY (`incidentId`,`patrolcarId`);
--
-- Indexes for table `incident`
--
ALTER TABLE `incident`
ADD PRIMARY KEY (`incidentid`);
--
-- Indexes for table `incidenttype`
--
ALTER TABLE `incidenttype`
ADD PRIMARY KEY (`incidenttypeid`);
--
-- Indexes for table `incident_status`
--
ALTER TABLE `incident_status`
ADD PRIMARY KEY (`statusId`);
--
-- Indexes for table `patrolcar`
--
ALTER TABLE `patrolcar`
ADD PRIMARY KEY (`patrolcarId`);
--
-- Indexes for table `patrolcar_status`
--
ALTER TABLE `patrolcar_status`
ADD PRIMARY KEY (`statusId`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `incident`
--
ALTER TABLE `incident`
MODIFY `incidentid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
79c0a3e123351767948c4f7dfd84b4ce2e7c8572
|
SQL
|
darwin1234/tictactoe-java-ee
|
/database/tictactoegame.sql
|
UTF-8
| 4,419
| 2.953125
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 28, 2019 at 02:00 AM
-- Server version: 10.1.40-MariaDB
-- PHP Version: 7.1.29
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `tictactoegame`
--
-- --------------------------------------------------------
--
-- Table structure for table `board`
--
CREATE TABLE `board` (
`id` int(11) NOT NULL,
`val1` varchar(11) NOT NULL,
`val2` varchar(11) NOT NULL,
`val3` varchar(11) NOT NULL,
`val4` varchar(11) NOT NULL,
`val5` varchar(11) NOT NULL,
`val6` varchar(11) NOT NULL,
`val7` varchar(11) NOT NULL,
`val8` varchar(11) NOT NULL,
`val9` varchar(11) NOT NULL,
`gamename` varchar(255) NOT NULL,
`creator` varchar(255) NOT NULL,
`oponent` varchar(255) NOT NULL,
`winner` varchar(255) NOT NULL,
`playerid_1` int(255) NOT NULL,
`playerid_2` int(255) NOT NULL,
`cell1` varchar(255) NOT NULL,
`cell2` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `board`
--
INSERT INTO `board` (`id`, `val1`, `val2`, `val3`, `val4`, `val5`, `val6`, `val7`, `val8`, `val9`, `gamename`, `creator`, `oponent`, `winner`, `playerid_1`, `playerid_2`, `cell1`, `cell2`) VALUES
(1, 'X', 'O', 'O', '-', 'X', '-', '-', '-', 'X', 'Test Room', 'darwin1234', 'justin', 'darwin1234', 1, 2, 'X', 'O'),
(2, 'O', 'O', 'O', '-', 'X', '-', '-', '-', 'X', 'tictactoe2', 'justin', 'darwin1234', 'justin', 2, 1, 'O', 'X'),
(3, 'X', 'X', 'O', 'X', 'O', 'O', 'X', 'O', 'X', 'draw', 'darwin1234', 'justin', 'darwin1234', 1, 2, 'X', 'O'),
(4, 'X', 'O', 'O', 'O', 'X', 'X', 'X', 'X', 'O', 'draw2', 'darwin1234', 'justin', 'Not Yet Started!', 1, 2, 'X', 'O');
-- --------------------------------------------------------
--
-- Table structure for table `tictactoe_table`
--
CREATE TABLE `tictactoe_table` (
`id` int(11) NOT NULL,
`string` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tictactoe_table`
--
INSERT INTO `tictactoe_table` (`id`, `string`) VALUES
(1, 'adaadadsasd');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`firstname` varchar(255) NOT NULL,
`lastname` varchar(255) NOT NULL,
`playername` varchar(255) NOT NULL,
`win` int(11) NOT NULL,
`lost` int(11) NOT NULL,
`draw` int(11) NOT NULL,
`cell` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `playername`, `win`, `lost`, `draw`, `cell`) VALUES
(1, 'darwin1234', 'donmock123', 'Darwin', 'Sese', 'darwin1234', 11, 0, 0, 'X'),
(2, 'justin1234', 'donmock123', 'Justin', 'Domingo', 'justin', 12, 0, 0, 'O');
-- --------------------------------------------------------
--
-- Table structure for table `winner`
--
CREATE TABLE `winner` (
`id` int(11) NOT NULL,
`playername` varchar(255) NOT NULL,
`score` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `board`
--
ALTER TABLE `board`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `tictactoe_table`
--
ALTER TABLE `tictactoe_table`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `board`
--
ALTER TABLE `board`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `tictactoe_table`
--
ALTER TABLE `tictactoe_table`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
c39ef1a0397181eef51278af2d9a2db810dd9f6a
|
SQL
|
swathigoru/Yelp-Dataset
|
/sgoru/bin/hw3createdb.sql
|
UTF-8
| 1,694
| 3.828125
| 4
|
[] |
no_license
|
/*CREATE STMTS */
CREATE TABLE users(
user_id varchar2(30),
user_name varchar2(50),
PRIMARY KEY (user_id)
);
/* business table columns:
loc = city + state
checkin_count = sum of all checkins for that bid */
CREATE TABLE business(
bid varchar2(30),
full_address varchar2(255),
open_status varchar2(10),
breview_count number,
bname varchar2(100),
loc varchar2(60),
bstars number,
checkin_count number,
PRIMARY KEY (bid)
);
CREATE TABLE categories(
cat_name varchar2(50),
subcat_name varchar2(40),
bid varchar2(30),
FOREIGN KEY (bid) REFERENCES business(bid) ON DELETE CASCADE
);
CREATE TABLE battributes(
bid varchar2(30),
att_name varchar2(255),
PRIMARY KEY (bid, att_name),
FOREIGN KEY (bid) REFERENCES business(bid) ON DELETE CASCADE
);
CREATE TABLE reviews(
review_id varchar2(30),
user_id varchar2(30),
stars number,
publish_date varchar2(10),
bid varchar2(30),
text clob,
funny_votes number,
useful_votes number,
cool_votes number,
PRIMARY KEY (review_id),
FOREIGN KEY (bid) REFERENCES business(bid) ON DELETE CASCADE
);
CREATE TABLE business_hours(
bid varchar2(30),
dayname varchar2(10),
openhr float,
closehr float,
loc varchar2(60),
PRIMARY KEY (bid, dayname),
FOREIGN KEY (bid) REFERENCES business(bid) ON DELETE CASCADE
);
CREATE INDEX cat_index
ON categories (cat_name);
CREATE INDEX sub_index
ON categories (subcat_name);
CREATE INDEX att_index
ON battributes (att_name);
| true
|
29a48d0fc05dbd3103793d895bedc78e437bd8ab
|
SQL
|
Kell-Stack/Where-Was-That-Filmed
|
/server/commands.sql
|
UTF-8
| 666
| 2.640625
| 3
|
[] |
no_license
|
CREATE TABLE media
(
actor_1 varchar(1000) default null,
actor_2 varchar(1000) default null,
actor_3 varchar(1000) default null,
director varchar(1000) default null,
distributor varchar(1000) default null,
fun_facts varchar(1000) default null,
locations varchar(1000) default null,
production_company varchar(1000) default null,
releaseyear varchar(1000) default null,
title varchar(1000) default null,
writer varchar(1000) default null
);
\COPY media FROM '~/Dev/WWTF/data/sffilmdata.csv' WITH (format csv);
ALTER TABLE media ADD COLUMN lat FLOAT;
ALTER TABLE media ADD COLUMN lng FLOAT;
ALTER TABLE media ADD COlUMN id SERIAL PRIMARY KEY;
| true
|
28c287abc7f70772c052e5cc9252efd7dba2ca1b
|
SQL
|
HuanaMari/project-Bank
|
/Bank-sql's/insertInto-branchAndAccount.sql
|
UTF-8
| 952
| 2.625
| 3
|
[] |
no_license
|
INSERT INTO branch (name,city,assets) VALUES
('Westpack','Sydney ',652898742),
('Westpack','Melbourne',574228365);
select * from branch;
INSERT INTO account (account_number,createdOn,balance,branchId)
VALUES
(FLOOR(30012346789 + RAND() * 3000000 ),now(),254127,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),78622,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),18450,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),578292,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),1458601,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),69020,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),54000,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),3272533,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),900,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),12400,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),172400,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),432750,1),
(FLOOR(30012346789 + RAND() * 3000000 ),now(),627850,1);
| true
|
b918b23e304c42e1e42a76a855fc206c1a368e60
|
SQL
|
sakho3600/OpenData_BolsaFamilia
|
/bf/queries.sql
|
UTF-8
| 1,307
| 4.125
| 4
|
[] |
no_license
|
-- Seleciona todos as ordens de pagamento na base de dados
SELECT
NIS_FAVORECIDO AS nis,
MES_COMPETENCIA as mes,
VALOR_PARCELA as valor
FROM
PAGAMENTO;
-- Seleciona todos os favorecidos na base de dados em ordem alfabetica
SELECT
NOME_FAVORECIDO AS nis,
CODIGO_SIAFI_MUNICIPIO AS nome
FROM
FAVORECIDO
ORDER BY nome ASC;
-- Ordena os estados em ordem maior beneficiado pelo programa bolsa familia
SELECT
m.uf AS estado,
SUM(p.valor_parcela) AS total
FROM
MUNICIPIO m
LEFT JOIN FAVORECIDO f ON f.CODIGO_SIAFI_MUNICIPIO = m.CODIGO_SIAFI_MUNICIPIO
JOIN PAGAMENTO p ON f.nis_favorecido = p.nis_favorecido
GROUP BY
estado;
-- Total de favorecidos por estado
SELECT
m.uf as estado,
COUNT(p.codigo_siafi_municipio) AS total_fav
FROM
MUNICIPIO m
LEFT JOIN FAVORECIDO f ON m.codigo_siafi_municipio = f.codigo_siafi_municipio
GROUP BY
estado
ORDER BY
total_fav;
-- Media de pagamentos
SELECT
AVG(valor_parcela) AS med_pag
FROM
PAGAMENTO;
-- Media de pagamentos por estado
SELECT
m.uf AS estado,
AVG(p.valor_parcela) AS med_state
FROM
MUNICIPIO m
LEFT JOIN FAVORECIDO f ON m.codigo_siafi_municipio = f.codigo_siafi_municipio
LEFT JOIN PAGAMENTO p ON f.nis_favorecido = p.nis_favorecido
GROUP BY
estado
ORDER BY
med_state;
| true
|
39627156a9cee6b65b3f7b09e142cddf7fb661d5
|
SQL
|
PhoenixSinister/FinalTest
|
/Complementos/DURALEX.sql
|
UTF-8
| 1,409
| 3.296875
| 3
|
[] |
no_license
|
CREATE DATABASE /*!32312 IF NOT EXISTS*/`duralex` /*!40100 DEFAULT CHARACTER SET utf8 */;
/*ACTUALIZACION */
USE `duralex`;
CREATE TABLE ROLES(
ID INT PRIMARY KEY NOT NULL,
DESCRIPCION VARCHAR(100)
);
insert into ROLES (ID, DESCRIPCION) values (0 , 'Sin Perfil');
insert into ROLES (ID, DESCRIPCION) values (1 , 'Gerente');
insert into ROLES (ID, DESCRIPCION) values (2 , 'Administrador');
insert into ROLES (ID, DESCRIPCION) values (3 , 'Secretaria');
insert into ROLES (ID, DESCRIPCION) values (4 , 'Cliente');
CREATE TABLE USUARIO(
ID INT PRIMARY KEY NOT NULL AUTO_INCREMENT
,RUT VARCHAR(100) NOT NULL
,NOMBRE VARCHAR(100) NOT NULL
,FECHA VARCHAR(100) DEFAULT NULL
,TIPO_PERSONA VARCHAR(100) NOT NULL
,DIRECCION VARCHAR(100) NOT NULL
,CELULAR VARCHAR(100) NOT NULL
,CONTRASENA VARCHAR(100) NOT NULL
,ID_PADRE VARCHAR(100)
);
insert into USUARIO (ID, RUT, NOMBRE, FECHA, TIPO_PERSONA, DIRECCION, CELULAR,CONTRASENA,ID_PADRE) VALUES (1,'1-9','Hugo','27-06-2017','Natural','[email protected]','9999999','1234',null);
insert into USUARIO (ID, RUT, NOMBRE, FECHA, TIPO_PERSONA, DIRECCION, CELULAR,CONTRASENA,ID_PADRE) VALUES (2,'2-9','Pedro','27-06-2017','Natural','[email protected]','9999999','1234',null);
insert into USUARIO (ID, RUT, NOMBRE, FECHA, TIPO_PERSONA, DIRECCION, CELULAR,CONTRASENA,ID_PADRE) VALUES (3,'3-9','Hijo','27-06-2017','Juridica','[email protected]','9999999','1234',2);
| true
|
de6849407a86e15fb70c7f05755c2befba41cb42
|
SQL
|
a11exe/job4j
|
/chapter_007/src/main/resources/create.sql
|
UTF-8
| 628
| 3.640625
| 4
|
[
"Apache-2.0"
] |
permissive
|
-- CREATE DATABASE items
-- WITH OWNER = "user"
-- ENCODING = 'UTF8'
-- TABLESPACE = pg_default
-- LC_COLLATE = 'Russian_Russia.1251'
-- LC_CTYPE = 'Russian_Russia.1251'
-- CONNECTION LIMIT = -1;
-- GRANT ALL ON DATABASE tracker TO "user";
-- REVOKE ALL ON DATABASE tracker FROM public;
DROP TABLE IF EXISTS comments;
DROP TABLE IF EXISTS item;
CREATE TABLE item(
item_id serial PRIMARY KEY,
item_name text NOT NULL,
item_desc text,
item_created timestamp NOT NULL
);
CREATE TABLE comments(
comment_id serial PRIMARY KEY,
comment_name text NOT NULL,
item_id int NOT NULL REFERENCES item (item_id) ON DELETE CASCADE
);
| true
|
6c4775b7eb5b4b9957138067e6e0c16addbcd1b7
|
SQL
|
ibrahimyesill/Akademi
|
/akademi.sql
|
UTF-8
| 6,981
| 3.234375
| 3
|
[
"MIT"
] |
permissive
|
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 100417
Source Host : localhost:3306
Source Schema : akademi
Target Server Type : MySQL
Target Server Version : 100417
File Encoding : 65001
Date: 05/05/2021 21:13:37
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for failed_jobs
-- ----------------------------
DROP TABLE IF EXISTS `failed_jobs`;
CREATE TABLE `failed_jobs` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `failed_jobs_uuid_unique`(`uuid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of failed_jobs
-- ----------------------------
-- ----------------------------
-- Table structure for migrations
-- ----------------------------
DROP TABLE IF EXISTS `migrations`;
CREATE TABLE `migrations` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of migrations
-- ----------------------------
INSERT INTO `migrations` VALUES (1, '2014_10_12_000000_create_users_table', 1);
INSERT INTO `migrations` VALUES (2, '2014_10_12_100000_create_password_resets_table', 1);
INSERT INTO `migrations` VALUES (3, '2019_08_19_000000_create_failed_jobs_table', 1);
INSERT INTO `migrations` VALUES (4, '2019_12_14_000001_create_personal_access_tokens_table', 1);
INSERT INTO `migrations` VALUES (5, '2014_10_12_200000_add_two_factor_columns_to_users_table', 2);
INSERT INTO `migrations` VALUES (6, '2021_05_02_163729_create_sessions_table', 2);
-- ----------------------------
-- Table structure for password_resets
-- ----------------------------
DROP TABLE IF EXISTS `password_resets`;
CREATE TABLE `password_resets` (
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
INDEX `password_resets_email_index`(`email`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of password_resets
-- ----------------------------
-- ----------------------------
-- Table structure for personal_access_tokens
-- ----------------------------
DROP TABLE IF EXISTS `personal_access_tokens`;
CREATE TABLE `personal_access_tokens` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`tokenable_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`tokenable_id` bigint UNSIGNED NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`abilities` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
`last_used_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `personal_access_tokens_token_unique`(`token`) USING BTREE,
INDEX `personal_access_tokens_tokenable_type_tokenable_id_index`(`tokenable_type`, `tokenable_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of personal_access_tokens
-- ----------------------------
-- ----------------------------
-- Table structure for sessions
-- ----------------------------
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE `sessions` (
`id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` bigint UNSIGNED NULL DEFAULT NULL,
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
`payload` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`last_activity` int NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `sessions_user_id_index`(`user_id`) USING BTREE,
INDEX `sessions_last_activity_index`(`last_activity`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sessions
-- ----------------------------
INSERT INTO `sessions` VALUES ('9FdxqxlF6990IfOWViZePKnyGo8pl00H9qTpjJHd', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoibE03eVdPMWVDUHZLTlFyT0lGZ3ZDMnp1S0V2OFg1Q05YbHNESDVCTiI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzM6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMC9jb25mZXJlbmNlcyI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1620070517);
INSERT INTO `sessions` VALUES ('GTYVhkf9PF9Wxp40s7bMoqENPctpg6SgWIAYaztR', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiUkhJWlh5UHZFN29WTFlzTmd4TGpuY1FQTU9namF1RzB4UVJQQWtsdSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzM6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMC9jb25mZXJlbmNlcyI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1620091615);
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`two_factor_secret` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
`two_factor_recovery_codes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
`remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `users_email_unique`(`email`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES (1, 'ibrahim', '[email protected]', NULL, '$2y$10$Iz5L0qIJyOwJ1uzJOGOtF.L5WfKiENhOHHSGOtdEIT.fH8nhQPTpC', NULL, NULL, NULL, '2021-05-02 16:42:07', '2021-05-02 16:42:07');
SET FOREIGN_KEY_CHECKS = 1;
| true
|
7501603329b1d0fc4cf3054bb02a78c982feaf10
|
SQL
|
JulianArbini97/holbertonschool-higher_level_programming
|
/0x0D-SQL_introduction/4-first_table.sql
|
UTF-8
| 168
| 2.609375
| 3
|
[] |
no_license
|
-- Script that creates a table called first_table in the current database --
CREATE TABLE first_table (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(256));
| true
|
920c7b3648bbc8b8dfaa9937b11f9159d0d61a96
|
SQL
|
maartenpaauw/IRDBMS
|
/Week 1/opdracht_11.sql
|
UTF-8
| 1,063
| 2.84375
| 3
|
[] |
no_license
|
/**
Opdracht 11
Voeg jezelf toe als patient aan de tabel patient_archief om deze testen.
Gebruik SYSDATE om de kolom lst_bijwerkdatum te vullen.
*/
-- EIGEN ANTWOORD
INSERT INTO patient_archief
(patient_nr, patient_sofi_nr, patient_achternaam, patient_voornaam, patient_tussenvoegsel, patient_adres, patient_plaats, patient_provincie, patient_postcode, patient_geboortedatum, patient_tel_nr, lst_bijwerkdat)
VALUES
(62480, 123456789, 'Paauw', 'Maarten', NULL, 'Cornelis Houtmanstraat 9B', 'Den Haag', 'ZH', '2593 RD',
DATE('1993-01-02'), '0612345678', NOW());
-- SCHOOL ANTWOORD
INSERT INTO patient_archief (patient_nr, patient_sofi_nr,
patient_achternaam, patient_voornaam, patient_tussenvoegsel,
patient_adres, patient_plaats, patient_provincie, patient_postcode,
patient_geboortedatum, patient_tel_nr, lst_bijwerkdat) VALUES ('999999',
'193293431', 'Manen', 'Alex', 'van', 'Zernikedreef 1', 'Leiden', 'ZH', '2333 CK',
'06-01-1984', '0648134008', NOW());
| true
|
cb84f3d96af87b3144cb2595fae368b83f41fefe
|
SQL
|
MLClark/Bookmarks
|
/Benefit Specific/COBRA/BEK/BEK PROBENEFITS QE/bek-qe-research.sql
|
UTF-8
| 3,231
| 3.359375
| 3
|
[] |
no_license
|
select * from benefit_plan_desc where current_date between effectivedate and enddate and current_timestamp between createts and endts;
select * from person_bene_election where current_timestamp between createts and endts and personid = '324' and benefitsubclass = '60';
(select distinct personid from person_bene_election where current_timestamp between createts and endts and personid = '358'
and benefitsubclass in ('10','11','14','60','61') and benefitelection = 'E' and selectedoption = 'Y' and effectivedate < enddate);
( select distinct de.dependentid as dependentid, pne.name, pnd.name, pbe.effectivedate
from dependent_enrollment de
join person_names pne
on pne.personid = de.personid
and pne.nametype = 'Legal'
and current_date between pne.effectivedate and pne.enddate
and current_timestamp between pne.createts and pne.endts
join person_names pnd
on pnd.personid = de.dependentid
and pnd.nametype = 'Dep'
and current_date between pnd.effectivedate and pnd.enddate
and current_timestamp between pnd.createts and pnd.endts
and pnd.effectivedate < pnd.enddate
join person_vitals pvd
on pvd.personid = de.dependentid
and current_date between pvd.effectivedate and pvd.enddate
and current_timestamp between pvd.createts and pvd.endts
join person_dependent_relationship pdr
on pdr.personid = de.personid
and pdr.dependentid = de.dependentid
and current_date between pdr.effectivedate and pdr.enddate
and current_timestamp between pdr.createts and pdr.endts
and pdr.effectivedate < pdr.enddate
join person_employment pe
on pe.personid = de.personid
and current_date between pe.effectivedate and pe.enddate
and current_timestamp between pe.createts and pe.endts
join person_bene_election pbe
on pbe.personid = de.personid
and pbe.benefitsubclass in ('10','11','14','60')
and pbe.selectedoption = 'Y'
and current_date between pbe.effectivedate and pbe.enddate
and current_timestamp between pbe.createts and pbe.endts
where current_timestamp between de.createts and de.endts
and de.benefitsubclass in ('10','11','14','60')
and pe.emplstatus = 'A'
and pbe.benefitelection <> 'W'
and date_part('year',de.enddate)=date_part('year',current_date)
and de.dependentid not in
(select distinct de.dependentid from dependent_enrollment de
join person_dependent_relationship pdr
on pdr.personid = de.personid
and pdr.dependentid = de.dependentid
and current_date between pdr.effectivedate and pdr.enddate
and current_timestamp between pdr.createts and pdr.endts
and pdr.effectivedate < pdr.enddate
where current_date between de.effectivedate and de.enddate
and current_timestamp between de.createts and de.endts
and de.effectivedate < de.enddate
and de.benefitsubclass in ('10','11','14','60')
)
) ;
select * from dependent_enrollment where dependentid = '575';
select * from person_employment where emplstatus = 'T' and emplevent = 'Death';
select * from person_maritalstatus pm where pm.maritalstatus = 'D'
| true
|
4dab79782a8847419930a41d22a52b9cadad896f
|
SQL
|
khl1956/amis
|
/km42/Mykolenko/database.sql
|
UTF-8
| 2,826
| 3.375
| 3
|
[] |
no_license
|
/*==============================================================*/
/* DBMS name: ORACLE Version 11g */
/* Created on: 12.11.2017 16:27:47 */
/*==============================================================*/
alter table "Booking"
drop constraint FK_BOOKING_REFERENCE_FLAT;
alter table "Booking"
drop constraint FK_BOOKING_TO_BOOK_F_USER;
alter table "Booking"
drop constraint FK_BOOKING_TO_LEASE__USER;
drop table "Booking" cascade constraints;
drop table "Flat" cascade constraints;
drop table "User" cascade constraints;
/*==============================================================*/
/* Table: "Booking" */
/*==============================================================*/
create table "Booking"
(
"booking_status" boolean not null,
"booking_startdate" DATE not null,
"booking_finishdate" DATE not null,
"flat_adress" CHAR(25),
"user_email" CHAR(25),
"user_type" SMALLINT,
"Use_user_email" CHAR(25),
"Use_user_type" SMALLINT,
constraint PK_BOOKING primary key ("booking_startdate", "booking_finishdate")
);
/*==============================================================*/
/* Table: "Flat" */
/*==============================================================*/
create table "Flat"
(
"flat_id" INTEGER,
"flat_adress" CHAR(25) not null,
"flat_price" NUMBER(8) not null,
"flat_type" CHAR(25) not null,
constraint PK_FLAT primary key ("flat_adress")
);
/*==============================================================*/
/* Table: "User" */
/*==============================================================*/
create table "User"
(
"user_firstname" CHAR(25) not null,
"user_secondname" CHAR(25) not null,
"user_email" CHAR(25) not null,
"user_pass" CHAR(25) not null,
"user_type" SMALLINT not null,
constraint PK_USER primary key ("user_email", "user_type")
);
alter table "Booking"
add constraint FK_BOOKING_REFERENCE_FLAT foreign key ("flat_adress")
references "Flat" ("flat_adress");
alter table "Booking"
add constraint FK_BOOKING_TO_BOOK_F_USER foreign key ("Use_user_email", "Use_user_type")
references "User" ("user_email", "user_type");
alter table "Booking"
add constraint FK_BOOKING_TO_LEASE__USER foreign key ("user_email", "user_type")
references "User" ("user_email", "user_type");
| true
|
b06d179a7dbfef3064c6b6003d5e6c94bafc7e3d
|
SQL
|
zheynov/Instwitt
|
/src/main/resources/SQLStartScript/StartScript.sql
|
UTF-8
| 1,064
| 3.796875
| 4
|
[] |
no_license
|
DROP DATABASE IF EXISTS profiles_db;
CREATE DATABASE IF NOT EXISTS profiles_db;
USE profiles_db;
CREATE TABLE profiles_db.profile
(
profile_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
firstName VARCHAR(30),
lastName VARCHAR(30),
birthDate DATE,
email VARCHAR(30) UNIQUE ,
age INT(30) DEFAULT NULL,
sex VARCHAR(30),
city VARCHAR(30),
phoneNumber VARCHAR(30)
);
CREATE TABLE profiles_db.users
(
user_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
firstName VARCHAR(30) NOT NULL,
lastName VARCHAR(30) NOT NULL,
email VARCHAR(30) NOT NULL UNIQUE,
login VARCHAR(30) NOT NULL UNIQUE,
password VARCHAR(30) NOT NULL,
profile_id INT NOT NULL,
FOREIGN KEY (profile_id) REFERENCES profile (profile_id) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE post (
post_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
user_id INT NOT NULL,
text VARCHAR(1024),
post_date DATETIME NOT NULL,
photo LONGBLOB,
FOREIGN KEY (user_id) REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE
);
| true
|
8ff004f4f207bb5b0823c5a34cbfa75971ce1704
|
SQL
|
mtalbot1516/final-project
|
/Archived:Legacy/schema.sql
|
UTF-8
| 1,566
| 2.671875
| 3
|
[
"MIT"
] |
permissive
|
-- Creating table for finalProject
CREATE TABLE realtor_data (
last_update_date DATE NOT NULL,
permalink VARCHAR(150) NOT NULL,
status VARCHAR(20) NOT NULL,
list_date DATE NOT NULL,
list_price INT NOT NULL,
property_id INT NOT NULL,
community VARCHAR(10) NOT NULL,
listing_id INT NOT NULL,
price_reduced_amount INT NOT NULL,
primary_photo_href VARCHAR(150) NOT NULL,
source_type VARCHAR(10) NOT NULL,
description_year_built INT NOT NULL,
description_sold_price INT NOT NULL,
description_baths_full INT NOT NULL,
description_baths_half INT NOT NULL,
description_lot_sqft INT NOT NULL,
description_sqft INT NOT NULL,
description_baths INT NOT NULL,
description_sub_type VARCHAR(5) NOT NULL,
description_garage INT NOT NULL,
description_stories INT NOT NULL,
description_beds INT NOT NULL,
description_type VARCHAR(20) NOT NULL,
flags_is_new_construction VARCHAR(5) NOT NULL,
flags_is_foreclosure VARCHAR(5) NOT NULL,
flags_is_new_listing VARCHAR(5) NOT NULL,
location_address_postal_code INT NOT NULL,
location_address_state VARCHAR(20) NOT NULL,
location_address_coordinate_lon INT NOT NULL,
location_address_coordinate_lat INT NOT NULL,
location_address_city VARCHAR(25) NOT NULL,
location_address_state_code VARCHAR(2) NOT NULL,
location_address_line VARCHAR(100) NOT NULL,
location_street_view_url VARCHAR(150) NOT NULL,
location_county_name VARCHAR(25) NOT NULL,
community_description_name VARCHAR(4) NOT NULL,
PRIMARY KEY (listing_id)
);
| true
|
efe01d3a52d318f30e759ee23b98355322e70994
|
SQL
|
VeselinAtanasov/mysql-database-demos
|
/mysql-database-demos/12_DatabaseBasicsMySQLRetake Exam-30Jul2019/tasks/01_CreateTable.sql
|
UTF-8
| 1,590
| 4.0625
| 4
|
[] |
no_license
|
CREATE DATABASE `colonial_blog_db`;
USE `colonial_blog_db`;
CREATE TABLE `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(30) NOT NULL UNIQUE,
`password` VARCHAR(30) NOT NULL,
`email` VARCHAR(50) NOT NULL
);
CREATE TABLE `categories` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`category` VARCHAR(30) NOT NULL
);
CREATE TABLE `articles` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`title` VARCHAR(50) NOT NULL,
`content` TEXT NOT NULL,
`category_id` INT,
CONSTRAINT fk_articles_categories FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`)
);
CREATE TABLE `users_articles` (
`user_id` INT,
`article_id` INT,
CONSTRAINT fk_users_articles_users
FOREIGN KEY (`user_id`)
REFERENCES `users`(`id`),
CONSTRAINT fk_users_articles_articles
FOREIGN KEY (`article_id`)
REFERENCES `articles`(`id`)
);
CREATE TABLE `comments` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`comment` VARCHAR(255) NOT NULL,
`article_id` INT NOT NULL,
`user_id` INT NOT NULL,
CONSTRAINT fk_comments_articles FOREIGN KEY (`article_id`) REFERENCES `articles`(`id`),
CONSTRAINT fk_comments_users FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
);
CREATE TABLE `likes`(
`id` INT AUTO_INCREMENT PRIMARY KEY,
`article_id` INT,
`comment_id` INT,
`user_id` INT NOT NULL,
CONSTRAINT fk_likes_articles FOREIGN KEY (`article_id`) REFERENCES `articles`(`id`),
CONSTRAINT fk_likes_comments FOREIGN KEY (`comment_id`) REFERENCES `comments`(`id`),
CONSTRAINT fk_likes_users FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
);
| true
|
f02b4931820582cb350c7c043a137db7e2c4682a
|
SQL
|
ManviMM/TSF_bank
|
/bankingsys.sql
|
UTF-8
| 2,745
| 3.34375
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 10, 2021 at 06:26 PM
-- Server version: 10.4.19-MariaDB
-- PHP Version: 8.0.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `tsf`
--
-- --------------------------------------------------------
--
-- Table structure for table `data`
--
CREATE TABLE `data` (
`id` int(5) NOT NULL,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`accno` varchar(20) NOT NULL,
`balance` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `data`
--
INSERT INTO `data` (`id`, `name`, `email`, `accno`, `balance`) VALUES
(1, 'Manvi', '[email protected]', 'UIN00010241', 80000),
(2, 'Ayushi', '[email protected]', 'UIN00010245', 40000),
(3, 'Digza', '[email protected]', 'UIN00010248', 66000),
(4, 'Joe', '[email protected]', 'UIN00010250', 75000),
(5, 'Nikhil', '[email protected]', 'UIN00010251', 83000),
(6, 'Aditya', '[email protected]', 'UIN00010255', 40000);
-- --------------------------------------------------------
--
-- Table structure for table `history`
--
CREATE TABLE `history` (
`id` int(2) NOT NULL,
`transcat` datetime DEFAULT current_timestamp(),
`sender` varchar(20) NOT NULL,
`receiver` varchar(20) NOT NULL,
`balance` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `history`
--
INSERT INTO `history` (`id`, `transcat`, `sender`, `receiver`, `balance`) VALUES
(1, '2021-07-10 19:36:21', 'Aditya', 'Digza', 2000),
(2, '2021-07-10 20:42:19', 'Ayushi', 'Nikhil', 3000),
(3, '2021-07-10 20:44:28', 'Manvi', 'Joe', 6000),
(4, '2021-07-10 20:45:34', 'Digza', 'Ayushi', 4000),
(5, '2021-07-10 20:58:38', 'Manvi', 'Aditya', 4000),
(6, '2021-07-10 20:59:00', 'Nikhil', 'Joe', 5000);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `data`
--
ALTER TABLE `data`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `history`
--
ALTER TABLE `history`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `data`
--
ALTER TABLE `data`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `history`
--
ALTER TABLE `history`
MODIFY `id` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
7543e5891d8fb4122873f680098af7d21e40ac37
|
SQL
|
MeGaDeTH91/SoftUni
|
/C# DB/Databases Basics/04 Definition and DataTypes/Def and DataTypes/04. Insert Records in Both Tables/08 Create Table Users.sql
|
UTF-8
| 957
| 3.21875
| 3
|
[] |
no_license
|
USE Minions
CREATE TABLE Users(
Id BIGINT IDENTITY NOT NULL,
Username VARCHAR(30) UNIQUE NOT NULL,
Password VARCHAR(26) NOT NULL,
ProfilePicture VARBINARY(MAX),
LastLoginTime DATETIME,
IsDeleted BIT
CONSTRAINT PK_Users PRIMARY KEY(Id)
)
INSERT INTO Users(Username, Password, ProfilePicture, LastLoginTime, IsDeleted)
VALUES
('Marto', '123456', NULL, NULL, 1)
INSERT INTO Users(Username, Password, ProfilePicture, LastLoginTime, IsDeleted)
VALUES
('Mar1', '21443', NULL, NULL, 1)
INSERT INTO Users(Username, Password, ProfilePicture, LastLoginTime, IsDeleted)
VALUES
('Marto2', '3123456', NULL, NULL, 1)
INSERT INTO Users(Username, Password, ProfilePicture, LastLoginTime, IsDeleted)
VALUES
('Marto3', '4123456', NULL, NULL, 1)
INSERT INTO Users(Username, Password, ProfilePicture, LastLoginTime, IsDeleted)
VALUES
('Marto4', '5123456', NULL, NULL, 1)
INSERT INTO Users(Username, Password, IsDeleted)
VALUES
('Martoss', '5123456', 1)
| true
|
22c4d96b4659de8cdf14853d7d0040dcbb679553
|
SQL
|
vijayalakshmikulkarni/CoronaPreventionKit
|
/target/m2e-wtp/web-resources/ims.sql
|
UTF-8
| 359
| 2.609375
| 3
|
[] |
no_license
|
DROP DATABASE imsDb;
CREATE DATABASE imsDb;
USE imsDb;
CREATE TABLE products(
id int primary key,
productName varchar(40) not null,
cost int not null,
productDescription varchar(40) not null,
);
CREATE TABLE kitDetails(
id int not null,
coronaKitId int not null,
productId int not null,
quantity int not null,
amount int not null,
);
| true
|
fc79be89b5b32e28fdf2d7ef5edcc710f1f62872
|
SQL
|
clarasmith/collegeconnect
|
/build_database.sql
|
UTF-8
| 2,243
| 3.75
| 4
|
[] |
no_license
|
-- Francys Scott, Cali Stenson, Megan Chen, Clara, Jessie.
-- Rosie Hackathon - March 8 2014
-- SQL for basic database for events.
-- This script only gets run one time! from this point onwards, the website should update the database.
-- First, specify the database / server that we access.
-- Note: haven't made this part yet - not yet exists.
use fscott_db;
-- Now clean out any existing table of the same name.
drop table if exists event;
drop table if exists user;
drop table if exists connection;
drop table if exists ride;
drop table if exists study;
drop table if exists studybuddy;
create table event (
eid int auto_increment not null,
name varchar(60),
event_date date,
event_time time,
address varchar(50),
photo_id varchar(30),
description varchar(500),
primary key(eid)
);
create table user(
uid int auto_increment not null primary key,
username varchar(20),
password varchar(20),
email varchar(30),
photo_id varchar(30)
);
create table study (
eid int auto_increment not null,
tme varchar(50),
department varchar(50),
course varchar(50),
primary key(eid)
);
create table connection(
uid int,
-- this is the uid from user table
eid int,
-- this is the event id from the event table
primary key (uid,eid),
foreign key (uid) references user,
foreign key (eid) references event
);
create table ride(
rid int auto_increment not null primary key;
);
-- Now this works
-- test with example user
insert into user values(null,'tester', 'testpassword', 'mchen4', '600499299992114');
-- test with an example item:
insert into event values (1468722776673580, 'Rosie Hackathon @ Wellesley: Collaborate for change, build stuff, have fun!', '2014-03-08', '11:00:00-18:00:00','21 Wellesley College Road','10100672860583886', 'Hey Wellesley! Want to learn new skills and show off your programming chops? Come to the Rosie Hackathon @ Wellesley!');
-- test with example connection: classic insert.
insert into connection values(1, 1468722776673580);
-- testing to see if this all worked.
-- select (username, email) from (user) where email = 'mchen4';
-- select (username, email, name) from (user, event) where uid in (select uid from connection where eid="1468722776673580");
| true
|
a5e69c6df712f5316e0f3a371e86465d98c3b496
|
SQL
|
markbellingham/HyperAV
|
/Database scripts/queries.sql
|
UTF-8
| 1,549
| 3.921875
| 4
|
[] |
no_license
|
SELECT stFName AS "First Name",stLName AS "Last Name",loName AS "Location"
FROM hyperAV_staff join hyperAV_location ON hyperAV_location.locationid = hyperAV_staff.locationid
WHERE hyperAV_location.loName = 'HyperAv London';
SELECT su.suName AS "Supplier Name", pr.prName AS "Product Name", sod.stOrderQuantity AS "Order Quantity"
FROM hyperAV_stockorderdetails sod JOIN hyperAV_stock st ON sod.stockID = st.stockID JOIN hyperAV_products pr ON st.prModelNo = pr.prModelNo JOIN hyperAV_supplier su ON sod.supplierID = su.supplierID
WHERE sod.stDeliveryDate IS NULL;
SELECT CONCAT(cu.cuFName, ' ', cu.cuLName) AS "Customer Name", o.orDate AS "Order Date", o.orTotal AS "Order Total"
FROM hyperAV_orders o JOIN hyperAV_customer cu ON o.customerID = cu.customerID
WHERE o.ortotal > 100
ORDER BY o.orTotal;
SELECT SUM(orTotal) AS "Total Sales", lo.loName AS "Location"
FROM hyperAV_orders o JOIN hyperAV_staff st ON o.staffID = st.staffID JOIN hyperAV_location lo ON st.locationID = lo.locationID
GROUP BY lo.locationID;
SELECT AVG(orTotal) AS "Average Sales"
FROM hyperAV_orders o JOIN hyperAV_staff st ON o.staffID = st.staffID JOIN hyperAV_location lo ON st.locationID = lo.locationID
WHERE lo.locationID = 4;
SELECT prName, prPrice, odQuantity, orDate, orTotal, orDeliverDate, orPaymentMethod FROM hyperAV_orders o JOIN hyperAV_orderdetails od ON o.orderID = od.orderID JOIN hyperAV_stock st ON od.stockID = st.stockID JOIN hyperAV_products pr ON st.prModelNo = pr.prModelNo WHERE o.customerID = 2;
| true
|
9964797f187299dec4b32df34dc5278f53fb16bc
|
SQL
|
johnmahugu/angel
|
/labour/labour.sql
|
UTF-8
| 3,174
| 3.125
| 3
|
[] |
no_license
|
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 10, 2014 at 10:29 PM
-- Server version: 5.5.24-log
-- PHP Version: 5.3.13
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `labour`
--
-- --------------------------------------------------------
--
-- Table structure for table `feedback`
--
CREATE TABLE IF NOT EXISTS `feedback` (
`username` varchar(100) NOT NULL,
`history` varchar(500) NOT NULL,
`feedback` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `org`
--
CREATE TABLE IF NOT EXISTS `org` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`address` varchar(200) NOT NULL,
`email` varchar(100) NOT NULL,
`key` varchar(200) NOT NULL,
`phone` varchar(12) NOT NULL,
`status` int(2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `org`
--
INSERT INTO `org` (`id`, `name`, `username`, `password`, `address`, `email`, `key`, `phone`, `status`) VALUES
(1, 'Deepanker Saxena', '', '', '', '', '', '', 0),
(3, 'D', 'a', 'a', 'A-417 , VIT MENS HOSTEL', '[email protected]', '', '919486767007', 0);
-- --------------------------------------------------------
--
-- Table structure for table `rating`
--
CREATE TABLE IF NOT EXISTS `rating` (
`username` varchar(100) NOT NULL,
`rating` int(5) NOT NULL,
`total` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rating`
--
INSERT INTO `rating` (`username`, `rating`, `total`) VALUES
('arun', 4, 6);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`age` int(4) NOT NULL,
`phone` varchar(20) NOT NULL,
`languages` varchar(300) NOT NULL,
`loc1` varchar(200) NOT NULL,
`loc2` varchar(200) NOT NULL,
`aadhar` varchar(100) NOT NULL,
`imagepath` varchar(100) NOT NULL,
`status` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `name`, `username`, `password`, `age`, `phone`, `languages`, `loc1`, `loc2`, `aadhar`, `imagepath`, `status`) VALUES
(2, 'Deepanker Saxena', 'abcd', 'abcd', 24, '919486767007', '', 'a', 'India', 'a', '', 0),
(12, 'Arub', 'arun', 'arun', 45, '45', ' English Hindi Telugu Tamil', '45', '45', '45', '', 0);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.