diff --git a/INFO-1273 (Databases 1)/Labs/Lab 6/SQL outline.txt b/INFO-1273 (Databases 1)/Labs/Lab 6/SQL outline.txt new file mode 100644 index 0000000..79eb5a6 --- /dev/null +++ b/INFO-1273 (Databases 1)/Labs/Lab 6/SQL outline.txt @@ -0,0 +1,76 @@ +Customers + ID + First name + Last name + Street Address + City + Province/State + Postal Code + Phone Number + Email Address + +Purpose: +Tracks who the client is and how to contact them. + +Relationship: +One customer can have multiple contracts. + +Contracts + Contract ID (unique identifier) + Customer ID (links to the customer) + Building Street Address + City + Province/State + Postal Code + Scheduled Date + Scheduled Time + Employee ID (employee assigned to the job) + +Purpose: +Tracks each job being performed. + +Relationships: +Each contract belongs to one customer. +Each contract is handled by one employee. +Each contract can contain multiple rooms. + +Rooms + Room ID + Contract ID + Room Name + Paint ID + +Purpose: +Tracks individual areas being painted for each contract. + +Relationships: +Each room belongs to one contract. +Each room uses one paint color. + +Inventory + Paint ID + Paint Name + Cost Per Can + Quantity + +Purpose: +Tracks paint options and pricing so customers know how much each paint can costs. + +Relationships: +One paint type can be used in many rooms. + +Employees + Employee ID + First Name + Last Name + Address + Postal Code + Hire Date + Salary + +Purpose: +Tracks the staff doing the work. + +Relationship: +One employee can be assigned to multiple contracts. +Each contract has exactly one employee. diff --git a/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db.sql b/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db.sql new file mode 100644 index 0000000..2117521 --- /dev/null +++ b/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db.sql @@ -0,0 +1,172 @@ +CREATE DATABASE IF NOT EXISTS `paintingbusiness` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */; +USE `paintingbusiness`; +-- MySQL dump 10.13 Distrib 8.0.45, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: paintingbusiness +-- ------------------------------------------------------ +-- Server version 5.5.5-10.4.32-MariaDB + +/*!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 `contracts` +-- + +DROP TABLE IF EXISTS `contracts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `contracts` ( + `contract_id` int(11) NOT NULL, + `customer_id` int(11) NOT NULL, + `employee_id` int(11) NOT NULL, + `address` varchar(255) NOT NULL, + `scheduled_for` datetime NOT NULL, + PRIMARY KEY (`contract_id`), + KEY `customer_id` (`customer_id`), + KEY `employee_id` (`employee_id`), + CONSTRAINT `contracts_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`), + CONSTRAINT `contracts_ibfk_2` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `contracts` +-- + +LOCK TABLES `contracts` WRITE; +/*!40000 ALTER TABLE `contracts` DISABLE KEYS */; +INSERT INTO `contracts` VALUES (1,1,2,'123 Maple St','2026-04-10 10:00:00'),(2,2,1,'45 Oak Ave','2026-04-12 09:00:00'),(3,3,3,'78 Pine Rd','2026-04-15 13:30:00'); +/*!40000 ALTER TABLE `contracts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `customers` +-- + +DROP TABLE IF EXISTS `customers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `customers` ( + `customer_id` int(11) NOT NULL, + `first_name` varchar(25) NOT NULL, + `last_name` varchar(30) NOT NULL, + `address` varchar(255) NOT NULL, + `phone` varchar(15) NOT NULL, + `email` varchar(30) NOT NULL, + PRIMARY KEY (`customer_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `customers` +-- + +LOCK TABLES `customers` WRITE; +/*!40000 ALTER TABLE `customers` DISABLE KEYS */; +INSERT INTO `customers` VALUES (1,'John','Smith','123 Maple St','416-555-1111','john.smith@email.com'),(2,'Sarah','Johnson','45 Oak Ave','416-555-2222','sarah.j@email.com'),(3,'Michael','Brown','78 Pine Rd','416-555-3333','m.brown@email.com'); +/*!40000 ALTER TABLE `customers` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `employees` +-- + +DROP TABLE IF EXISTS `employees`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `employees` ( + `employee_id` int(11) NOT NULL, + `first_name` varchar(25) NOT NULL, + `last_name` varchar(30) NOT NULL, + `address` varchar(255) NOT NULL, + `hire_date` datetime NOT NULL, + `salary` int(11) NOT NULL, + PRIMARY KEY (`employee_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `employees` +-- + +LOCK TABLES `employees` WRITE; +/*!40000 ALTER TABLE `employees` DISABLE KEYS */; +INSERT INTO `employees` VALUES (1,'David','Wilson','22 Birch Ln','2022-04-12 09:00:00',45000),(2,'Emily','Davis','91 Cedar Dr','2023-01-20 09:00:00',42000),(3,'Robert','Taylor','15 Spruce Ct','2021-07-15 09:00:00',48000); +/*!40000 ALTER TABLE `employees` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `inventory` +-- + +DROP TABLE IF EXISTS `inventory`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `inventory` ( + `paint_id` int(11) NOT NULL, + `paint_name` varchar(30) NOT NULL, + `cost_per_can` decimal(2,0) NOT NULL, + `quantity` int(11) NOT NULL, + PRIMARY KEY (`paint_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `inventory` +-- + +LOCK TABLES `inventory` WRITE; +/*!40000 ALTER TABLE `inventory` DISABLE KEYS */; +INSERT INTO `inventory` VALUES (1,'Arctic White',30,50),(2,'Ocean Blue',35,40),(3,'Sunset Yellow',28,60); +/*!40000 ALTER TABLE `inventory` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `rooms` +-- + +DROP TABLE IF EXISTS `rooms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `rooms` ( + `room_id` int(11) NOT NULL, + `contract_id` int(11) NOT NULL, + `paint_id` int(11) NOT NULL, + `room_name` varchar(30) NOT NULL, + PRIMARY KEY (`room_id`), + KEY `contract_id` (`contract_id`), + KEY `paint_id` (`paint_id`), + CONSTRAINT `rooms_ibfk_1` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`contract_id`), + CONSTRAINT `rooms_ibfk_2` FOREIGN KEY (`paint_id`) REFERENCES `inventory` (`paint_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `rooms` +-- + +LOCK TABLES `rooms` WRITE; +/*!40000 ALTER TABLE `rooms` DISABLE KEYS */; +INSERT INTO `rooms` VALUES (1,1,1,'Living Room'),(2,2,2,'Bedroom'),(3,3,3,'Kitchen'); +/*!40000 ALTER TABLE `rooms` 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 2026-03-14 20:50:41 diff --git a/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db_ip.sql b/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db_ip.sql new file mode 100644 index 0000000..8c29dde --- /dev/null +++ b/INFO-1273 (Databases 1)/Labs/Lab 6/customer_db_ip.sql @@ -0,0 +1,46 @@ +CREATE DATABASE IF NOT EXISTS paintingBusiness; +USE paintingBusiness; + +CREATE TABLE IF NOT EXISTS customers( + customer_id INT NOT NULL PRIMARY KEY, + first_name VARCHAR(25) NOT NULL, + last_name VARCHAR(30) NOT NULL, + `address` VARCHAR(255) NOT NULL, + phone VARCHAR(15) NOT NULL, + email VARCHAR(30) NOT NULL +); + +CREATE TABLE IF NOT EXISTS employees( + employee_id INT NOT NULL PRIMARY KEY, + first_name VARCHAR(25) NOT NULL, + last_name VARCHAR(30) NOT NULL, + `address` VARCHAR(255) NOT NULL, + hire_date DATETIME NOT NULL, + salary INT NOT NULL +); + +CREATE TABLE IF NOT EXISTS inventory( + paint_id INT NOT NULL PRIMARY KEY, + paint_name VARCHAR(30) NOT NULL, + cost_per_can DECIMAL(5,2) NOT NULL, + quantity INT NOT NULL +); + +CREATE TABLE IF NOT EXISTS contracts( + contract_id INT NOT NULL PRIMARY KEY, + customer_id INT NOT NULL, + employee_id INT NOT NULL, + `address` VARCHAR(255) NOT NULL, + scheduled_for DATETIME NOT NULL, + FOREIGN KEY (customer_id) REFERENCES customers(customer_id), + FOREIGN KEY (employee_id) REFERENCES employees(employee_id) +); + +CREATE TABLE IF NOT EXISTS rooms( + room_id INT NOT NULL PRIMARY KEY, + contract_id INT NOT NULL, + paint_id INT NOT NULL, + room_name VARCHAR(30) NOT NULL, + FOREIGN KEY (contract_id) REFERENCES contracts(contract_id), + FOREIGN KEY (paint_id) REFERENCES inventory(paint_id) +); \ No newline at end of file