Change Database Scheme according to DBv1.sql

This commit is contained in:
Tim
2025-05-07 14:52:36 +02:00
parent 6c065633d2
commit ad7d921a1d
4 changed files with 107 additions and 3 deletions

View File

@@ -11,5 +11,4 @@ public class WebshopApplication {
System.setProperty("server.port", BASE_PORT);
SpringApplication.run(WebshopApplication.class, args);
}
}

View File

@@ -0,0 +1,56 @@
CREATE TABLE IF NOT EXISTS ArticleConfigurations(
id INTEGER PRIMARY KEY NOT NULL,
articleId INTEGER NOT NULL,
name TEXT NOT NULL,
FOREIGN KEY (articleId) REFERENCES Articles(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS Customers(
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL, --nachname
surname TEXT NOT NULL, --vorname,
address TEXT NOT NULL,
country TEXT NOT NULL,
zip TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS Orders(
id INTEGER PRIMARY KEY NOT NULL,
customerId INTEGER NOT NULL,
time INTEGER NOT NULL, --unix millis or epoch, TBD
FOREIGN KEY (customerId) REFERENCES Customers(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
-- Each Article-Configuration in the order gets their own of this one
CREATE TABLE IF NOT EXISTS OrderItems(
orderId INTEGER NOT NULL,
articleId INTEGER NOT NULL,
articleConfId INTEGER NULL,
amount INTEGER NOT NULL,
CONSTRAINT cAmount CHECK (amount > 0),
FOREIGN KEY (orderId) REFERENCES Orders(id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (articleId) REFERENCES Articles(id)
ON DELETE SET NULL
ON UPDATE CASCADE,
FOREIGN KEY (articleConfId) REFERENCES ArticleConfigurations(id)
ON DELETE SET NULL
ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS Accounts(
id INTEGER PRIMARY KEY NOT NULL,
customerId INTEGER NOT NULL,
email TEXT NOT NULL,
password TEXT NOT NULL,
lang_i18n TEXT NOT NULL,
FOREIGN KEY (customerId) REFERENCES Customers(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);

View File

@@ -27,4 +27,4 @@ CREATE TABLE IF NOT EXISTS Reviews(
content TEXT NULL,
FOREIGN KEY (articleId) REFERENCES Articles(id),
CONSTRAINT c_rating CHECK ( rating >= 0 AND rating <= 10)
)
);

View File

@@ -1,2 +1,51 @@
# webshop
# DPS Webshop
Webshop-Projekt für htw saar Digitale Produktionssysteme
## Prerequisites
- ``git`` installed & added to PATH
- Java Development Kit 17 (we recommend using OpenJDK with Hotspot) installed & added to PATH
- Maven >= 3.9.9 installed & added to PATH
- ``npm`` installed & added to PATH
- An Internet Connection (to download the Maven Dependencies)
## Compile
- Make sure you fulfill all prerequisites
- Clone files & submodules with:
```shell
git clone git@github.com:FlorianSpeicher04/webshop.git
```
### Backend
- (Optional) change the ``BASE_PORT`` in [WebshopApplication.java](00-backend/src/main/java/de/htwsaar/webshop/WebshopApplication.java) from 8085 to something else
- Compile with:
```shell
mvn clean package
```
### Frontend
- Compile with:
```shell
npm install
```
## Run
### 🥰 Unix Systems
- TODO: make script
```shell
```
### 🤮 Windows
- TODO: make script
```shell
```
# Contributors
- Laura Katharina Dolibois
- Mathusan Saravanapavan
- Florian Speicher
- Tim Wall