From bcd8d096baa34e858ff9e4705246835c63245781 Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Fri, 5 Jun 2026 20:11:09 +0200 Subject: [PATCH] Solution1 --- .idea/.gitignore | 5 +++ .idea/inspectionProfiles/Project_Default.xml | 18 +++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/modules.xml | 8 ++++ .idea/rda_task_1_create_database.iml | 8 ++++ .idea/vcs.xml | 6 +++ task.sql | 37 ++++++++++++++++++- 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rda_task_1_create_database.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..c7bd4da --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6c912fd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rda_task_1_create_database.iml b/.idea/rda_task_1_create_database.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/rda_task_1_create_database.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/task.sql b/task.sql index 0a66d93..a917189 100644 --- a/task.sql +++ b/task.sql @@ -1 +1,36 @@ -# Write your SQL code for the database creation here. Good luck! +CREATE DATABASE IF NOT EXISTS ShopDB; + +USE ShopDB; + +CREATE TABLE IF NOT EXISTS Products ( + ID INT AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR(100) NOT NULL, + Description VARCHAR(100), + Price INT NOT NULL, + WarehouseAmount INT NOT NULL +); + +CREATE TABLE IF NOT EXISTS Customers ( + ID INT AUTO_INCREMENT PRIMARY KEY, + FirstName VARCHAR(50) NOT NULL, + LastName VARCHAR(50) NOT NULL, + Email VARCHAR(100) NOT NULL, + Address VARCHAR(100) +); + +CREATE TABLE IF NOT EXISTS Orders ( + ID INT AUTO_INCREMENT PRIMARY KEY, + CustomerID INT, + Date DATE NOT NULL, + + FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL +); + +CREATE TABLE IF NOT EXISTS OrderItems ( + ID INT AUTO_INCREMENT PRIMARY KEY, + OrderID INT, + ProductID INT, + + FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE SET NULL, + FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL +);