refactor database schema: improve table definitions and add missing fields

This commit is contained in:
Fabian Schieder 2026-02-17 21:15:51 +01:00
parent 1432598160
commit de7a69e4c6

View File

@ -1,4 +1,5 @@
Table categories { Table categories
{
categoryID int [pk] categoryID int [pk]
name varchar(255) name varchar(255)
parentCategoryID int parentCategoryID int
@ -6,30 +7,34 @@ Table categories {
Ref: "categories"."parentCategoryID" < "categories"."categoryID" Ref: "categories"."parentCategoryID" < "categories"."categoryID"
Table brands { Table brands
{
brandID int [pk] brandID int [pk]
name varchar(255) name varchar(255)
} }
Table products { Table products
{
productID int [pk] productID int [pk]
categoryID int categoryID int
brandID int brandID int
model varchar(255) model varchar(255)
ean varchar(20)
description text description text
imagePath varchar(255)
} }
Ref: "products"."categoryID" < "categories"."categoryID" Ref: "products"."categoryID" < "categories"."categoryID"
Ref: "products"."brandID" < "brands"."brandID" Ref: "products"."brandID" < "brands"."brandID"
Table shops { Table shops
{
shopID int [pk] shopID int [pk]
name varchar(255) name varchar(255)
website varchar(255) website varchar(255)
} }
Table offers { Table offers
{
offerID int [pk] offerID int [pk]
productID int productID int
shopID int shopID int
@ -43,14 +48,16 @@ Table offers {
Ref: "offers"."productID" < "products"."productID" Ref: "offers"."productID" < "products"."productID"
Ref: "offers"."shopID" < "shops"."shopID" Ref: "offers"."shopID" < "shops"."shopID"
Table attributes { Table attributes
{
attributeID int [pk] attributeID int [pk]
name varchar(255) name varchar(255)
unit varchar(50) unit varchar(50)
dataType varchar(20) dataType varchar(20)
} }
Table categoryAttributes { Table categoryAttributes
{
categoryID int categoryID int
attributeID int attributeID int
} }
@ -58,7 +65,8 @@ Table categoryAttributes {
Ref: "categoryAttributes"."categoryID" < "categories"."categoryID" Ref: "categoryAttributes"."categoryID" < "categories"."categoryID"
Ref: "categoryAttributes"."attributeID" < "attributes"."attributeID" Ref: "categoryAttributes"."attributeID" < "attributes"."attributeID"
Table productAttributes { Table productAttributes
{
productID int productID int
attributeID int attributeID int
valueString varchar(255) valueString varchar(255)
@ -72,21 +80,32 @@ Ref: "productAttributes"."attributeID" < "attributes"."attributeID"
Table users {
Table users
{
userID int [pk] userID int [pk]
email varchar(255) email varchar(255)
passwordHash varchar(255) passwordHash varchar(255)
displayName varchar(255) displayName varchar(255)
isActive boolean isActive boolean
createdAt timestamp createdAt timestamp
profilePicture varchar(255)
} }
Table roles { Table roles
{
roleID int [pk] roleID int [pk]
name varchar(50) name varchar(50)
} }
Table userRoles { Table userRoles
{
userID int userID int
roleID int roleID int
} }
@ -94,7 +113,8 @@ Table userRoles {
Ref: "userRoles"."userID" < "users"."userID" Ref: "userRoles"."userID" < "users"."userID"
Ref: "userRoles"."roleID" < "roles"."roleID" Ref: "userRoles"."roleID" < "roles"."roleID"
Table userFavorites { Table userFavorites
{
userID int userID int
productID int productID int
createdAt timestamp createdAt timestamp
@ -103,7 +123,8 @@ Table userFavorites {
Ref: "userFavorites"."userID" < "users"."userID" Ref: "userFavorites"."userID" < "users"."userID"
Ref: "userFavorites"."productID" < "products"."productID" Ref: "userFavorites"."productID" < "products"."productID"
Table priceAlerts { Table priceAlerts
{
alertID int [pk] alertID int [pk]
userID int userID int
productID int productID int
@ -115,7 +136,8 @@ Table priceAlerts {
Ref: "priceAlerts"."userID" < "users"."userID" Ref: "priceAlerts"."userID" < "users"."userID"
Ref: "priceAlerts"."productID" < "products"."productID" Ref: "priceAlerts"."productID" < "products"."productID"
Table notifications { Table notifications
{
notificationID int [pk] notificationID int [pk]
userID int userID int
title varchar(255) title varchar(255)
@ -126,7 +148,8 @@ Table notifications {
Ref: "notifications"."userID" < "users"."userID" Ref: "notifications"."userID" < "users"."userID"
Table reviews { Table reviews
{
reviewID int [pk] reviewID int [pk]
userID int userID int
productID int productID int
@ -138,7 +161,8 @@ Table reviews {
Ref: "reviews"."userID" < "users"."userID" Ref: "reviews"."userID" < "users"."userID"
Ref: "reviews"."productID" < "products"."productID" Ref: "reviews"."productID" < "products"."productID"
Table userSessions { Table userSessions
{
sessionID varchar(128) [pk] sessionID varchar(128) [pk]
userID int userID int
expiresAt timestamp expiresAt timestamp