fix datatypes, erd
This commit is contained in:
parent
60e1e72bff
commit
8092510098
2 changed files with 79 additions and 61 deletions
114
erd.dbml
114
erd.dbml
|
@ -1,61 +1,79 @@
|
||||||
// Use DBML to define your database structure
|
// https://dbdiagram.io/d/
|
||||||
// Docs: https://dbml.dbdiagram.io/docs
|
// Kraut&Rübel ERD
|
||||||
|
|
||||||
Table Kunde {
|
Table Customer {
|
||||||
KundenNr integer [primary key]
|
id string [primary key]
|
||||||
Vorname string
|
first_name string
|
||||||
Nachname string
|
last_name string
|
||||||
Strasse string
|
street string
|
||||||
Geburstdatum timestamp
|
birth_date timestamp
|
||||||
HausNr string
|
house_number string
|
||||||
PLZ integer
|
postal_code integer
|
||||||
Email string
|
email string
|
||||||
Telefon integer
|
phone integer
|
||||||
Ort string
|
city string
|
||||||
}
|
}
|
||||||
|
|
||||||
Table Bestellung {
|
Table Order {
|
||||||
BestellNr integer [primary key]
|
id string [primary key]
|
||||||
KundenNr integer
|
customer Customer
|
||||||
Rechnungsbetrag integer
|
invoice_amount integer
|
||||||
Bestelldatum timestamp
|
order_date timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
Table Zutat {
|
Table Ingredient {
|
||||||
ZutatenNr integer [primary key]
|
id string [primary key]
|
||||||
Bezeichnung string
|
designation string
|
||||||
Bestand integer
|
stock integer
|
||||||
Nettopreis integer
|
net_price integer
|
||||||
Einheit string
|
unit string
|
||||||
Kohlenhydrate integer
|
carbonhydrates integer
|
||||||
Kalorien integer
|
calories integer
|
||||||
Protein integer
|
protein integer
|
||||||
}
|
}
|
||||||
|
|
||||||
Table Lieferant {
|
Table Supplier {
|
||||||
LieferantenNr integer [primary key]
|
id string [primary key]
|
||||||
Ort string
|
city string
|
||||||
Strasse string
|
street string
|
||||||
Email string
|
email string
|
||||||
Telefon string
|
phone string
|
||||||
Liferantenname string
|
supplier_name string
|
||||||
HausNr string
|
house_number string
|
||||||
PLZ integer
|
postal_code integer
|
||||||
}
|
}
|
||||||
|
|
||||||
Table Lieferant_contains_Zutaten {
|
Table Recipe {
|
||||||
LieferantenNr integer [primary key]
|
id string [primary key]
|
||||||
ZutatenNr integer [primary key]
|
preperation_time integer
|
||||||
|
name string
|
||||||
|
description string
|
||||||
|
instructions string
|
||||||
}
|
}
|
||||||
|
|
||||||
Table Bestellung_contains_Zutaten {
|
Table RecipeContainsIngredients {
|
||||||
BestellNr integer [primary key]
|
recipe string [primary key]
|
||||||
ZutatenNr integer [primary key]
|
ingredient string [primary key]
|
||||||
Menge integer
|
amount integer
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref: Bestellung.KundenNr > Kunde.KundenNr
|
Table SupplierContainsIngredients {
|
||||||
Ref: Lieferant_contains_Zutaten.LieferantenNr > Lieferant.LieferantenNr
|
supplier string [primary key]
|
||||||
Ref: Lieferant_contains_Zutaten.ZutatenNr > Zutat.ZutatenNr
|
ingredient string [primary key]
|
||||||
Ref: Bestellung_contains_Zutaten.BestellNr > Bestellung.BestellNr
|
delivery_cost integer
|
||||||
Ref: Bestellung_contains_Zutaten.ZutatenNr > Zutat.ZutatenNr
|
delivery_time integer
|
||||||
|
}
|
||||||
|
|
||||||
|
Table OrderContainsIngredients {
|
||||||
|
order string [primary key]
|
||||||
|
ingredient string [primary key]
|
||||||
|
quantity integer
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref: Order.customer > Customer.id
|
||||||
|
Ref: SupplierContainsIngredients.supplier > Supplier.id
|
||||||
|
Ref: SupplierContainsIngredients.ingredient > Ingredient.id
|
||||||
|
Ref: OrderContainsIngredients.order > Order.id
|
||||||
|
Ref: OrderContainsIngredients.ingredient > Ingredient.id
|
||||||
|
Ref: RecipeContainsIngredients.recipe > Recipe.id
|
||||||
|
Ref: RecipeContainsIngredients.ingredient > Ingredient.id
|
||||||
|
|
|
@ -3,7 +3,7 @@ from dataclasses import dataclass, asdict
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Customer:
|
class Customer:
|
||||||
customer_id: int
|
id: str
|
||||||
first_name: str
|
first_name: str
|
||||||
last_name: str
|
last_name: str
|
||||||
street: str
|
street: str
|
||||||
|
@ -20,8 +20,8 @@ class Customer:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Order:
|
class Order:
|
||||||
order_id: int
|
id: str
|
||||||
customer: Customer
|
customer: Customer.id
|
||||||
invoice_amount: int
|
invoice_amount: int
|
||||||
order_date: str # Assuming timestamp as a string for simplicity
|
order_date: str # Assuming timestamp as a string for simplicity
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class Order:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Ingredient:
|
class Ingredient:
|
||||||
ingredient_id: int
|
id: str
|
||||||
designation: str
|
designation: str
|
||||||
stock: int
|
stock: int
|
||||||
net_price: int
|
net_price: int
|
||||||
|
@ -46,7 +46,7 @@ class Ingredient:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Supplier:
|
class Supplier:
|
||||||
supplier_id: int
|
id: str
|
||||||
city: str
|
city: str
|
||||||
street: str
|
street: str
|
||||||
email: str
|
email: str
|
||||||
|
@ -60,7 +60,7 @@ class Supplier:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Recipe:
|
class Recipe:
|
||||||
recipe_id: int
|
id: str
|
||||||
preperation_time: int
|
preperation_time: int
|
||||||
name: str
|
name: str
|
||||||
description: str
|
description: str
|
||||||
|
@ -70,15 +70,15 @@ class Recipe:
|
||||||
return {k: str(v) for k, v in asdict(self).items()}
|
return {k: str(v) for k, v in asdict(self).items()}
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SupplierContainsIngredients:
|
class RecipeContainsIngredients:
|
||||||
recipe: Recipe
|
recipe: Recipe.id
|
||||||
ingredient: Ingredient
|
ingredient: Ingredient.id
|
||||||
amount: int
|
amount: int
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SupplierContainsIngredients:
|
class SupplierContainsIngredients:
|
||||||
supplier: Supplier
|
supplier: Supplier.id
|
||||||
ingredient: Ingredient
|
ingredient: Ingredient.id
|
||||||
delivery_cost: int
|
delivery_cost: int
|
||||||
delivery_time: int
|
delivery_time: int
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ class SupplierContainsIngredients:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class OrderContainsIngredients:
|
class OrderContainsIngredients:
|
||||||
order: Order
|
order: Order.id
|
||||||
ingredient: Ingredient
|
ingredient: Ingredient.id
|
||||||
quantity: int
|
quantity: int
|
||||||
|
|
||||||
def dict(self):
|
def dict(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue