automated terminal push
All checks were successful
learn org at code.softwareshinobi.com/databases.softwareshinobi.com/pipeline/head This commit looks good
All checks were successful
learn org at code.softwareshinobi.com/databases.softwareshinobi.com/pipeline/head This commit looks good
This commit is contained in:
320
server/datasets/local-real-estate.sql
Normal file
320
server/datasets/local-real-estate.sql
Normal file
@@ -0,0 +1,320 @@
|
||||
CREATE DATABASE `LOCAL_REAL_ESTATE` DEFAULT CHARACTER SET utf8mb4;
|
||||
|
||||
USE `LOCAL_REAL_ESTATE`;
|
||||
|
||||
/* create tables of attributes */
|
||||
CREATE TABLE Property(
|
||||
address VARCHAR(50) NOT NULL,
|
||||
ownerName VARCHAR(30),
|
||||
price INT,
|
||||
PRIMARY KEY(address)
|
||||
);
|
||||
|
||||
CREATE TABLE House(
|
||||
address VARCHAR(50) NOT NULL,
|
||||
ownerName VARCHAR(30),
|
||||
price INT,
|
||||
bedrooms INT,
|
||||
bathrooms INT,
|
||||
size INT,
|
||||
FOREIGN KEY(address) REFERENCES Property(address)
|
||||
);
|
||||
|
||||
CREATE TABLE BusinessProperty(
|
||||
address VARCHAR(50) NOT NULL,
|
||||
ownerName VARCHAR(30),
|
||||
price INT,
|
||||
type CHAR(20),
|
||||
size INT,
|
||||
FOREIGN KEY(address) REFERENCES Property(address)
|
||||
);
|
||||
|
||||
CREATE TABLE Firm(
|
||||
id INT NOT NULL,
|
||||
name VARCHAR(30),
|
||||
address VARCHAR(50),
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
CREATE TABLE Agent(
|
||||
agentId INT NOT NULL,
|
||||
name VARCHAR(30),
|
||||
phone CHAR(12),
|
||||
firmId INT NOT NULL,
|
||||
dateStarted DATE,
|
||||
PRIMARY KEY(agentId),
|
||||
FOREIGN KEY(firmId) REFERENCES Firm(id)
|
||||
);
|
||||
|
||||
CREATE TABLE Listing(
|
||||
address VARCHAR(50),
|
||||
agentId INT,
|
||||
mlsNumber INT PRIMARY KEY,
|
||||
dataListed DATE,
|
||||
FOREIGN KEY(agentId) REFERENCES Agent(agentId),
|
||||
FOREIGN KEY(address) REFERENCES Property(address)
|
||||
);
|
||||
|
||||
CREATE TABLE Buyer(
|
||||
id INT NOT NULL,
|
||||
name VARCHAR(30),
|
||||
phone CHAR(12),
|
||||
propertyType CHAR(20),
|
||||
bedrooms INT,
|
||||
bathrooms INT,
|
||||
businessPropertyType CHAR(20),
|
||||
minimumPreferredPrice INT,
|
||||
maximumPreferredPrice INT,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
CREATE TABLE Work_With(
|
||||
buyerId INT,
|
||||
agentId INT,
|
||||
FOREIGN KEY(buyerId) REFERENCES Buyer(id),
|
||||
FOREIGN KEY(agentId) REFERENCES Agent(agentId)
|
||||
);
|
||||
|
||||
/* create an assertion */
|
||||
/*
|
||||
CREATE ASSERTION PROPERTY_AGENT_PROJECTION CHECK
|
||||
(NOT EXISTS
|
||||
(SELECT L1.address
|
||||
FROM Listings L1, Listings L2
|
||||
WHERE L1.address = L2.address AND L1.agentId != L2.agentId
|
||||
)
|
||||
);
|
||||
*/
|
||||
/* insert records to each tables, each table has at least 5 records */
|
||||
/* 10 records into Property */
|
||||
INSERT INTO Property
|
||||
VALUES('2350 Gibson Road', 'John Smith', 235000);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('197 Watson Street', 'Raymond Chou', 789000);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('2525 Pottsdamer Street', 'Jim Lee', 100500);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('193 Love BLVD', 'Kim Abudal', 930000);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('647 Maston Road', 'Robert Clue', 135000);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('1350 Navada Street', 'Jack Green', 674090);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('256 Florida Street', 'Michael Kohen', 179280);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('1717 Kansas Street', 'Leah Mars', 345000);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('2613 Academic Way', 'Marry Song', 997050);
|
||||
|
||||
INSERT INTO Property
|
||||
VALUES('179 Tinker Road', 'Leon Kant', 90000);
|
||||
|
||||
/* 5 records into House */
|
||||
INSERT INTO House
|
||||
VALUES('2350 Gibson Road', 'John Smith', 235000, 3, 2, 196);
|
||||
|
||||
INSERT INTO House
|
||||
VALUES('197 Watson Street', 'Raymond Chou', 789000, 2, 4, 203);
|
||||
|
||||
INSERT INTO House
|
||||
VALUES('2525 Pottsdamer Street', 'Jim Lee', 100500, 2, 3, 180);
|
||||
|
||||
INSERT INTO House
|
||||
VALUES('193 Love BLVD', 'Kim Abudal', 930000, 3, 2, 401);
|
||||
|
||||
INSERT INTO House
|
||||
VALUES('647 Maston Road', 'Robert Clue', 135000, 3, 2, 102);
|
||||
|
||||
/* 5 records into BusinessProperty */
|
||||
INSERT INTO BusinessProperty
|
||||
VALUES('1350 Navada Street', 'Jack Green', 674090, 'office space', 467);
|
||||
|
||||
INSERT INTO BusinessProperty
|
||||
VALUES('256 Florida Street', 'Michael Kohen', 179280, 'gas station', 245);
|
||||
|
||||
INSERT INTO BusinessProperty
|
||||
VALUES('1717 Kansas Street', 'Leah Mars', 345000, 'office space', 356);
|
||||
|
||||
INSERT INTO BusinessProperty
|
||||
VALUES('2613 Academic Way', 'Marry Song', 997050, 'office space', 670);
|
||||
|
||||
INSERT INTO BusinessProperty
|
||||
VALUES('179 Tinker Road', 'Leon Kant', 90000, 'store front', 128);
|
||||
|
||||
/* 5 records into Firm */
|
||||
INSERT INTO Firm
|
||||
VALUES(135210, 'Goldman Sash', '799 Georgia Way');
|
||||
|
||||
INSERT INTO Firm
|
||||
VALUES(146277, 'Holloway', '124 Texas Street');
|
||||
|
||||
INSERT INTO Firm
|
||||
VALUES(165034, 'Good Target', '135 California Street');
|
||||
|
||||
INSERT INTO Firm
|
||||
VALUES(230754, 'Cozy Home', '277 Beach Road');
|
||||
|
||||
INSERT INTO Firm
|
||||
VALUES(210211, 'Fast Searcher', '1010 Alas Road');
|
||||
|
||||
/* 10 records into Agent */
|
||||
INSERT INTO Agent
|
||||
VALUES(100, 'Leet Kim', '135145636', 210211, '2012-01-23');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(112, 'Jim Alpha', '171135636', 210211, '2012-03-26');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(123, 'George Grey', '176321636', 135210, '2015-02-23');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(145, 'Sarah Core', '135145909', 135210, '2016-07-03');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(168, 'Livia Watson', '137145638', 146277, '2014-01-17');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(189, 'Nik Ray', '135873630', 146277, '2014-01-28');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(201, 'Cris Paul', '136141236', 165034, '2016-05-23');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(223, 'Lena Clay', '137145123', 165034, '2014-08-19');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(267, 'Kevin Nil', '190145636', 230754, '2011-07-20');
|
||||
|
||||
INSERT INTO Agent
|
||||
VALUES(310, 'Hugh Grant', '132145639', 230754, '2012-12-31');
|
||||
|
||||
/* 10 records into Listing */
|
||||
INSERT INTO Listing
|
||||
VALUES('2350 Gibson Road', 100, 1212, '2013-02-04');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('197 Watson Street', 112, 1500, '2013-05-06');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('2525 Pottsdamer Street', 123, 1617, '2016-12-04');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('193 Love BLVD', 145, 1718, '2016-02-09');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('647 Maston Road', 168, 1900, '2014-12-19');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('1350 Navada Street', 189, 2101, '2015-06-06');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('256 Florida Street', 201, 2305, '2017-05-25');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('1717 Kansas Street', 223, 2500, '2014-12-04');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('2613 Academic Way', 267, 2790, '2013-10-01');
|
||||
|
||||
INSERT INTO Listing
|
||||
VALUES('179 Tinker Road', 310, 3001, '2015-09-05');
|
||||
|
||||
/* 6 records into Buyer */
|
||||
INSERT INTO Buyer
|
||||
VALUES(799, 'John Nay', '125345790', 'house', 3, 2, 'not applied', 100000, 635000);
|
||||
|
||||
INSERT INTO Buyer
|
||||
VALUES(801, 'Retina Grey', '146345790', 'house', 3, 2, 'not applied', 100000, 400000);
|
||||
|
||||
INSERT INTO Buyer
|
||||
VALUES(813, 'Reg Neal', '189345791', 'house', 2, 3, 'not applied', 300000, 635000);
|
||||
|
||||
INSERT INTO Buyer
|
||||
VALUES(845, 'Gena Sarah', '789345790', 'house', 3, 2, 'not applied', 200000, 960000);
|
||||
|
||||
INSERT INTO Buyer
|
||||
VALUES(875, 'Bill Clay', '888345798', 'not applied', 0, 0, 'office space', 100000, 900000);
|
||||
|
||||
INSERT INTO Buyer
|
||||
VALUES(999, 'Hilton Clag', '999345792', 'not applied', 0, 0, 'office space', 300000, 790000);
|
||||
|
||||
/* 6 records into Works_With */
|
||||
INSERT INTO Work_With
|
||||
VALUES(799, 100);
|
||||
|
||||
INSERT INTO Work_With
|
||||
VALUES(801, 145);
|
||||
|
||||
INSERT INTO Work_With
|
||||
VALUES(813, 123);
|
||||
|
||||
INSERT INTO Work_With
|
||||
VALUES(845, 168);
|
||||
|
||||
INSERT INTO Work_With
|
||||
VALUES(875, 189);
|
||||
|
||||
INSERT INTO Work_With
|
||||
VALUES(999, 223);
|
||||
|
||||
/* queries */
|
||||
/* 1st query */
|
||||
SELECT Listing.address
|
||||
FROM Listing, House
|
||||
WHERE Listing.address = House.address;
|
||||
|
||||
/* 2nd query */
|
||||
SELECT Listing.address, Listing.mlsNumber
|
||||
FROM Listing, House
|
||||
WHERE Listing.address = House.address;
|
||||
|
||||
/* 3rd query */
|
||||
SELECT Listing.address
|
||||
FROM Listing, House
|
||||
WHERE Listing.address = House.address AND House.bedrooms = 3 AND House.bathrooms = 2;
|
||||
|
||||
/* 4th query */
|
||||
SELECT address, price
|
||||
FROM House
|
||||
WHERE bedrooms = 3 AND bathrooms = 2 AND price >= 100000 AND price <= 250000
|
||||
ORDER BY price DESC;
|
||||
|
||||
/* 5th query */
|
||||
SELECT address, price
|
||||
FROM BusinessProperty
|
||||
WHERE type = 'office space'
|
||||
ORDER BY price DESC;
|
||||
|
||||
/* 6th query */
|
||||
SELECT agentId, Agent.name, phone, Firm.name, dateStarted
|
||||
FROM Agent, Firm
|
||||
WHERE Agent.firmId = Firm.id;
|
||||
|
||||
/* 7th query, agentId is indicated as 201 here */
|
||||
SELECT Property.*
|
||||
FROM Property, Listing
|
||||
WHERE Property.address = Listing.address AND Listing.agentId = 201;
|
||||
|
||||
/* 8th query */
|
||||
SELECT Agent.name AS Agent_Name, Buyer.name AS Buyer_Name
|
||||
FROM Agent, Buyer, Work_With
|
||||
WHERE Agent.agentId = Work_With.agentId AND Buyer.id = Work_With.buyerId;
|
||||
|
||||
/* 9th query, suppose the buyer's Id is 799 in our case */
|
||||
SELECT House.*
|
||||
FROM House, Buyer
|
||||
WHERE Buyer.id = 799 AND
|
||||
Buyer.bedrooms = House.bedrooms AND
|
||||
Buyer.bathrooms = House.bathrooms AND
|
||||
Buyer.minimumPreferredPrice <= House.price AND
|
||||
Buyer.maximumPreferredPrice >= House.price;
|
||||
|
||||
/* the end of program */
|
||||
1236
server/datasets/mega-mart-grocery.sql
Normal file
1236
server/datasets/mega-mart-grocery.sql
Normal file
File diff suppressed because it is too large
Load Diff
381
server/datasets/monaco-motors-dealership.sql
Normal file
381
server/datasets/monaco-motors-dealership.sql
Normal file
@@ -0,0 +1,381 @@
|
||||
|
||||
--
|
||||
-- Database: `MONACO_MOTORS`
|
||||
--
|
||||
CREATE DATABASE IF NOT EXISTS `MONACO_MOTORS` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci;
|
||||
|
||||
USE `MONACO_MOTORS`;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Customer`
|
||||
--
|
||||
|
||||
CREATE TABLE `Customer` (
|
||||
`CustomerID` char(8) NOT NULL,
|
||||
`AgentID` char(8) NOT NULL,
|
||||
`CustFirstName` varchar(15) NOT NULL,
|
||||
`CustLastName` varchar(15) NOT NULL,
|
||||
`PhoneNumber` varchar(12) NOT NULL,
|
||||
`Email` varchar(40) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Customer`
|
||||
--
|
||||
|
||||
INSERT INTO `Customer` (`CustomerID`, `AgentID`, `CustFirstName`, `CustLastName`, `PhoneNumber`, `Email`) VALUES
|
||||
('24863197', '89324037', 'Mark', 'Hunt', '3347852143', 'markymark@gmail.com'),
|
||||
('25463157', '85476932', 'Carly', 'Myers', '7897896325', 'carlyy478@gmail.com'),
|
||||
('45682178', '85264532', 'John', 'Miller', '3568421479', 'johnboy@hotmail.com'),
|
||||
('46525896', '32433468', 'Madison', 'Hart', '7892553001', 'lilmaddy@gmail.com'),
|
||||
('52147932', '78932145', 'Megan', 'Sellers', '3345893321', 'megmeg@hotmail.com'),
|
||||
('53247962', '85693248', 'Shelly', 'Jones', '4568423698', 'shellyjones@gmail.com'),
|
||||
('63222478', '45879632', 'Connor', 'Kirk', '3346953214', 'kirkkconnor@yahoo.com'),
|
||||
('64786233', '89324037', 'Logan', 'Hutchinson', '3345896789', 'loganhutch@yahoo.com'),
|
||||
('74859612', '45879632', 'Barbara', 'Brown', '3348529654', 'bigbarb400@hotmail.com'),
|
||||
('78527962', '54279634', 'Andrew', 'Jackson', '3345301438', 'andyjack@gmail.com'),
|
||||
('78962583', '85693248', 'Morgan', 'Stanley', '4562314862', 'morgstan78@yahoo.com'),
|
||||
('86321478', '85476932', 'Bill', 'Clark', '7892256541', 'bclrk@hotmail.com'),
|
||||
('88895214', '74125852', 'William', 'Martin', '6502287512', 'willmart@gmail.com');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Deal`
|
||||
--
|
||||
|
||||
CREATE TABLE `Deal` (
|
||||
`DealID` char(5) NOT NULL,
|
||||
`VehicleID` char(3) NOT NULL,
|
||||
`AgentID` char(8) NOT NULL,
|
||||
`CustomerID` char(8) NOT NULL,
|
||||
`InsuranceID` char(5) DEFAULT NULL,
|
||||
`DealDate` date NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Deal`
|
||||
--
|
||||
|
||||
INSERT INTO `Deal` (`DealID`, `VehicleID`, `AgentID`, `CustomerID`, `InsuranceID`, `DealDate`) VALUES
|
||||
('21115', '123', '32433468', '46525896', '78222', '2023-03-27'),
|
||||
('25839', '328', '78932145', '52147932', '21444', '2024-04-18'),
|
||||
('33658', '216', '74125852', '88895214', '26687', '2023-04-24'),
|
||||
('45523', '377', '45879632', '63222478', '11478', '2023-04-01'),
|
||||
('48624', '486', '54279634', '78527962', NULL, '2023-11-08'),
|
||||
('48876', '729', '85693248', '53247962', NULL, '2024-04-16'),
|
||||
('55896', '554', '45879632', '74859612', '44589', '2024-02-01'),
|
||||
('58221', '456', '85264532', '45682178', '22268', '2023-02-11'),
|
||||
('77885', '416', '85476932', '86321478', NULL, '2024-02-21'),
|
||||
('95632', '265', '89324037', '24863197', '56482', '2023-01-17');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Dealership`
|
||||
--
|
||||
|
||||
CREATE TABLE `Dealership` (
|
||||
`DealershipID` char(5) NOT NULL,
|
||||
`DistributorID` char(8) NOT NULL,
|
||||
`RegionID` char(3) NOT NULL,
|
||||
`RegionZIP` char(5) NOT NULL,
|
||||
`DealershipName` varchar(40) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Dealership`
|
||||
--
|
||||
|
||||
INSERT INTO `Dealership` (`DealershipID`, `DistributorID`, `RegionID`, `RegionZIP`, `DealershipName`) VALUES
|
||||
('32569', '45632479', '578', '58203', 'Winged Lion Motors'),
|
||||
('47823', '12347896', '334', '36081', 'Scuderia Speed'),
|
||||
('59823', '45324895', '578', '58203', 'Velocity Auto Haus'),
|
||||
('78962', '36589217', '334', '36081', 'Tridente Motors'),
|
||||
('85632', '36521789', '356', '36079', 'Galleria Motors'),
|
||||
('96523', '25863217', '356', '36079', 'Royal Stallion Motors');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Distributor`
|
||||
--
|
||||
|
||||
CREATE TABLE `Distributor` (
|
||||
`DistributorID` char(8) NOT NULL,
|
||||
`DistributorName` varchar(40) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Distributor`
|
||||
--
|
||||
|
||||
INSERT INTO `Distributor` (`DistributorID`, `DistributorName`) VALUES
|
||||
('12347896', 'Pfaff Reserve'),
|
||||
('25863217', 'EuroCar'),
|
||||
('36521789', 'Redline European'),
|
||||
('36589217', 'Romans International'),
|
||||
('45324895', 'European Exotic Center'),
|
||||
('45632479', 'James Edition');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Insurance`
|
||||
--
|
||||
|
||||
CREATE TABLE `Insurance` (
|
||||
`InsuranceID` char(5) NOT NULL,
|
||||
`PolicyType` varchar(15) NOT NULL,
|
||||
`RenewalDate` date NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Insurance`
|
||||
--
|
||||
|
||||
INSERT INTO `Insurance` (`InsuranceID`, `PolicyType`, `RenewalDate`) VALUES
|
||||
('11478', 'Full Coverage', '2024-04-01'),
|
||||
('21444', 'Full Coverage', '2020-04-18'),
|
||||
('22268', 'Liability', '2024-02-11'),
|
||||
('26687', 'Liability', '2024-04-24'),
|
||||
('44589', 'Full Coverage', '2020-02-01'),
|
||||
('56482', 'Full Coverage', '2024-01-17'),
|
||||
('78222', 'Full Coverage', '2024-03-27');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Manager`
|
||||
--
|
||||
|
||||
CREATE TABLE `Manager` (
|
||||
`ManagerID` char(8) NOT NULL,
|
||||
`DealershipID` char(5) NOT NULL,
|
||||
`DistributorID` char(8) NOT NULL,
|
||||
`MngrFirstName` varchar(15) NOT NULL,
|
||||
`MngrLastName` varchar(15) NOT NULL,
|
||||
`MngrSalary` decimal(8,2) NOT NULL,
|
||||
`MngrBonus` decimal(8,2) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Manager`
|
||||
--
|
||||
|
||||
INSERT INTO `Manager` (`ManagerID`, `DealershipID`, `DistributorID`, `MngrFirstName`, `MngrLastName`, `MngrSalary`, `MngrBonus`) VALUES
|
||||
('12345678', '59823', '45324895', 'John', 'Boling', 87900.00, 5100.23),
|
||||
('14458973', '96523', '25863217', 'Henry', 'Miller', 79025.99, 5200.60),
|
||||
('32556978', '78962', '36589217', 'Rachel', 'Smith', 81500.10, 2400.00),
|
||||
('45896324', '32569', '45632479', 'Sally', 'Mae', 75000.99, 4250.50),
|
||||
('52689974', '85632', '36521789', 'Lamar', 'Jackson', 91250.10, NULL),
|
||||
('58894123', '47823', '12347896', 'Kevin', 'Rogers', 71250.00, 8450.00);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Region`
|
||||
--
|
||||
|
||||
CREATE TABLE `Region` (
|
||||
`RegionID` char(3) NOT NULL,
|
||||
`RegionZIP` char(5) NOT NULL,
|
||||
`RegionName` varchar(15) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Region`
|
||||
--
|
||||
|
||||
INSERT INTO `Region` (`RegionID`, `RegionZIP`, `RegionName`) VALUES
|
||||
('334', '36081', 'EMEA'),
|
||||
('356', '36079', 'APJ'),
|
||||
('578', '58203', 'AMS');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Sales_Agent`
|
||||
--
|
||||
|
||||
CREATE TABLE `Sales_Agent` (
|
||||
`AgentID` char(8) NOT NULL,
|
||||
`ManagerID` char(8) NOT NULL,
|
||||
`DealershipID` char(5) NOT NULL,
|
||||
`AgentFirstName` varchar(15) NOT NULL,
|
||||
`AgentLastName` varchar(15) NOT NULL,
|
||||
`AgentSalary` decimal(9,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Sales_Agent`
|
||||
--
|
||||
|
||||
INSERT INTO `Sales_Agent` (`AgentID`, `ManagerID`, `DealershipID`, `AgentFirstName`, `AgentLastName`, `AgentSalary`) VALUES
|
||||
('28547962', '52689974', '85632', 'Jack', 'Hublot', 61258.00),
|
||||
('32433468', '52689974', '85632', 'Jennifer', 'Martin', 57950.99),
|
||||
('45698234', '12345678', '59823', 'Jordan', 'Myers', 43450.00),
|
||||
('45879632', '32556978', '78962', 'Stacy', 'Diaz', 47600.50),
|
||||
('54279634', '32556978', '78962', 'Marshall', 'Reese', 57180.00),
|
||||
('74125852', '58894123', '47823', 'Allison', 'Garner', 54800.00),
|
||||
('78932145', '14458973', '96523', 'Jasper', 'Sparks', 48650.99),
|
||||
('79621463', '45896324', '32569', 'Hubert', 'Davis', 52081.32),
|
||||
('85264532', '58894123', '47823', 'Paul', 'Werner', 51850.50),
|
||||
('85476932', '14458973', '96523', 'Mitchell', 'Fields', 42600.00),
|
||||
('85693248', '12345678', '59823', 'Alex', 'Smith', 47520.59),
|
||||
('89324037', '45896324', '32569', 'Benjamin', 'Gonzales', 49250.90);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Vehicle`
|
||||
--
|
||||
|
||||
CREATE TABLE `Vehicle` (
|
||||
`VehicleID` char(3) NOT NULL,
|
||||
`DealershipID` char(5) NOT NULL,
|
||||
`DistributorID` char(8) NOT NULL,
|
||||
`Make` varchar(40) NOT NULL,
|
||||
`Model` varchar(40) NOT NULL,
|
||||
`BodyType` varchar(40) NOT NULL,
|
||||
`ModelYear` int(11) NOT NULL,
|
||||
`Price` decimal(9,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `Vehicle`
|
||||
--
|
||||
|
||||
INSERT INTO `Vehicle` (`VehicleID`, `DealershipID`, `DistributorID`, `Make`, `Model`, `BodyType`, `ModelYear`, `Price`) VALUES
|
||||
('123', '85632', '36521789', 'Lamborghini', 'Aventador', 'Coupe', 2024, 421145.00),
|
||||
('216', '47823', '12347896', 'Ferrari', 'Roma', 'Coupe', 2024, 220340.00),
|
||||
('265', '32569', '45632479', 'Pagani', 'Huayra BC', 'Coupe', 2024, 2800000.00),
|
||||
('328', '96523', '25863217', 'Bugatti', 'Chiron Super Sport 300+', 'Coupe', 2024, 5790000.00),
|
||||
('349', '85632', '36521789', 'Lamborghini', 'Huracan STO', 'Coupe', 2024, 327835.00),
|
||||
('377', '78962', '36589217', 'Maserati', 'MC20 Cielo', 'Spyder', 2024, 281000.00),
|
||||
('416', '96523', '25863217', 'Rolls-Royce', 'Cullinan Black Badge', 'SUV', 2024, 388000.00),
|
||||
('456', '47823', '12347896', 'Ferrari', 'SF90 Stradale', 'Coupe', 2024, 516000.00),
|
||||
('486', '78962', '36589217', 'McLaren', 'Artura', 'Coupe', 2024, 185500.00),
|
||||
('532', '59823', '45324895', 'Aston Martin', 'DBS', 'Coupe', 2024, 336000.00),
|
||||
('554', '78962', '36589217', 'McLaren', 'GT', 'Coupe', 2024, 210000.00),
|
||||
('729', '59823', '45324895', 'Bentley', 'Continental GT Speed', 'Coupe', 2024, 335000.00);
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `Customer`
|
||||
--
|
||||
ALTER TABLE `Customer`
|
||||
ADD PRIMARY KEY (`CustomerID`),
|
||||
ADD KEY `AgentID` (`AgentID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Deal`
|
||||
--
|
||||
ALTER TABLE `Deal`
|
||||
ADD PRIMARY KEY (`DealID`),
|
||||
ADD KEY `VehicleID` (`VehicleID`),
|
||||
ADD KEY `AgentID` (`AgentID`),
|
||||
ADD KEY `CustomerID` (`CustomerID`),
|
||||
ADD KEY `InsuranceID` (`InsuranceID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Dealership`
|
||||
--
|
||||
ALTER TABLE `Dealership`
|
||||
ADD PRIMARY KEY (`DealershipID`),
|
||||
ADD KEY `DistributorID` (`DistributorID`),
|
||||
ADD KEY `RegionID` (`RegionID`,`RegionZIP`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Distributor`
|
||||
--
|
||||
ALTER TABLE `Distributor`
|
||||
ADD PRIMARY KEY (`DistributorID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Insurance`
|
||||
--
|
||||
ALTER TABLE `Insurance`
|
||||
ADD PRIMARY KEY (`InsuranceID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Manager`
|
||||
--
|
||||
ALTER TABLE `Manager`
|
||||
ADD PRIMARY KEY (`ManagerID`),
|
||||
ADD KEY `DealershipID` (`DealershipID`),
|
||||
ADD KEY `DistributorID` (`DistributorID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Region`
|
||||
--
|
||||
ALTER TABLE `Region`
|
||||
ADD PRIMARY KEY (`RegionID`,`RegionZIP`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Sales_Agent`
|
||||
--
|
||||
ALTER TABLE `Sales_Agent`
|
||||
ADD PRIMARY KEY (`AgentID`),
|
||||
ADD KEY `ManagerID` (`ManagerID`),
|
||||
ADD KEY `DealershipID` (`DealershipID`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Vehicle`
|
||||
--
|
||||
ALTER TABLE `Vehicle`
|
||||
ADD PRIMARY KEY (`VehicleID`),
|
||||
ADD KEY `DealershipID` (`DealershipID`),
|
||||
ADD KEY `DistributorID` (`DistributorID`);
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `Customer`
|
||||
--
|
||||
ALTER TABLE `Customer`
|
||||
ADD CONSTRAINT `Customer_ibfk_1` FOREIGN KEY (`AgentID`) REFERENCES `Sales_Agent` (`AgentID`);
|
||||
|
||||
--
|
||||
-- Constraints for table `Deal`
|
||||
--
|
||||
ALTER TABLE `Deal`
|
||||
ADD CONSTRAINT `Deal_ibfk_1` FOREIGN KEY (`VehicleID`) REFERENCES `Vehicle` (`VehicleID`),
|
||||
ADD CONSTRAINT `Deal_ibfk_2` FOREIGN KEY (`AgentID`) REFERENCES `Sales_Agent` (`AgentID`),
|
||||
ADD CONSTRAINT `Deal_ibfk_3` FOREIGN KEY (`CustomerID`) REFERENCES `Customer` (`CustomerID`),
|
||||
ADD CONSTRAINT `Deal_ibfk_4` FOREIGN KEY (`InsuranceID`) REFERENCES `Insurance` (`InsuranceID`);
|
||||
|
||||
--
|
||||
-- Constraints for table `Dealership`
|
||||
--
|
||||
ALTER TABLE `Dealership`
|
||||
ADD CONSTRAINT `Dealership_ibfk_1` FOREIGN KEY (`DistributorID`) REFERENCES `Distributor` (`DistributorID`),
|
||||
ADD CONSTRAINT `Dealership_ibfk_2` FOREIGN KEY (`RegionID`,`RegionZIP`) REFERENCES `Region` (`RegionID`, `RegionZIP`);
|
||||
|
||||
--
|
||||
-- Constraints for table `Manager`
|
||||
--
|
||||
ALTER TABLE `Manager`
|
||||
ADD CONSTRAINT `Manager_ibfk_1` FOREIGN KEY (`DealershipID`) REFERENCES `Dealership` (`DealershipID`),
|
||||
ADD CONSTRAINT `Manager_ibfk_2` FOREIGN KEY (`DistributorID`) REFERENCES `Distributor` (`DistributorID`);
|
||||
|
||||
--
|
||||
-- Constraints for table `Sales_Agent`
|
||||
--
|
||||
ALTER TABLE `Sales_Agent`
|
||||
ADD CONSTRAINT `Sales_Agent_ibfk_1` FOREIGN KEY (`ManagerID`) REFERENCES `Manager` (`ManagerID`),
|
||||
ADD CONSTRAINT `Sales_Agent_ibfk_2` FOREIGN KEY (`DealershipID`) REFERENCES `Dealership` (`DealershipID`);
|
||||
|
||||
--
|
||||
-- Constraints for table `Vehicle`
|
||||
--
|
||||
ALTER TABLE `Vehicle`
|
||||
ADD CONSTRAINT `Vehicle_ibfk_1` FOREIGN KEY (`DealershipID`) REFERENCES `Dealership` (`DealershipID`),
|
||||
ADD CONSTRAINT `Vehicle_ibfk_2` FOREIGN KEY (`DistributorID`) REFERENCES `Distributor` (`DistributorID`);
|
||||
4
server/datasets/user-readonly-create.sql
Normal file
4
server/datasets/user-readonly-create.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
CREATE USER 'readonly'@'%' IDENTIFIED BY 'readonly';
|
||||
|
||||
GRANT SELECT, SHOW VIEW ON *.* TO 'readonly'@'%' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
|
||||
9
server/datasets/user-shinobi-create.sql
Normal file
9
server/datasets/user-shinobi-create.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
CREATE USER 'shinobi'@'%' IDENTIFIED BY 'shinobi';
|
||||
|
||||
GRANT SELECT ON MONACO_MOTORS.* TO 'shinobi'@'%' IDENTIFIED BY 'shinobi';
|
||||
|
||||
GRANT SELECT ON LOCAL_REAL_ESTATE.* TO 'shinobi'@'%' IDENTIFIED BY 'shinobi';
|
||||
|
||||
GRANT SELECT ON MEGA_MART_GROCERY.* TO 'shinobi'@'%' IDENTIFIED BY 'shinobi';
|
||||
|
||||
Reference in New Issue
Block a user