lf5/data/create_strucure.surrealql
2024-02-08 21:13:25 +01:00

76 lines
No EOL
2.8 KiB
Text

DEFINE NAMESPACE krautundrueben;
USE NS krautundrueben;
DEFINE DATABASE stable;
USE DB stable;
DEFINE TABLE Customer SCHEMALESS;
DEFINE FIELD first_name ON TABLE Customer TYPE string;
DEFINE FIELD last_name ON TABLE Customer TYPE string;
DEFINE FIELD birth_date ON TABLE Customer TYPE string;
DEFINE FIELD phone ON TABLE Customer TYPE string;
DEFINE FIELD address ON TABLE Customer TYPE record<Address>;
DEFINE FIELD email ON TABLE Customer TYPE string
ASSERT string::is::email($value);
DEFINE TABLE Supplier SCHEMALESS;
DEFINE FIELD name ON TABLE Supplier TYPE string;
DEFINE FIELD phone ON TABLE Supplier TYPE string;
DEFINE FIELD address ON TABLE Supplier TYPE record<Address>;
DEFINE FIELD email ON TABLE Supplier TYPE string
ASSERT string::is::email($value);
DEFINE TABLE Ingredient SCHEMALESS;
DEFINE FIELD designation ON TABLE Ingredient TYPE string;
DEFINE FIELD unit ON TABLE Ingredient TYPE string;
DEFINE FIELD net_price ON TABLE Ingredient TYPE float;
DEFINE FIELD stock ON TABLE Ingredient TYPE int;
DEFINE FIELD calories ON TABLE Ingredient TYPE int;
DEFINE FIELD carbohydrates ON TABLE Ingredient TYPE float;
DEFINE FIELD protein ON TABLE Ingredient TYPE float;
DEFINE TABLE Order SCHEMALESS;
DEFINE FIELD invoice_amount ON TABLE Order TYPE float;
DEFINE FIELD net_price ON TABLE Order TYPE float;
DEFINE FIELD order_date ON TABLE Order TYPE string;
DEFINE FIELD customer ON TABLE Order TYPE record<Customer>;
DEFINE TABLE Recipe SCHEMALESS;
DEFINE FIELD preparation_time ON TABLE Recipe TYPE int;
DEFINE FIELD name ON TABLE Recipe TYPE string;
DEFINE FIELD description ON TABLE Recipe TYPE string;
DEFINE FIELD instructions ON TABLE Recipe TYPE string;
DEFINE TABLE Address SCHEMALESS;
DEFINE FIELD city ON TABLE Address TYPE string;
DEFINE FIELD street ON TABLE Address TYPE string;
DEFINE FIELD house_number ON TABLE Address TYPE string;
DEFINE FIELD postal_code ON TABLE Address TYPE string;
DEFINE TABLE RecipeContainsIngredients SCHEMALESS;
DEFINE FIELD amount ON TABLE RecipeContainsIngredients TYPE int;
DEFINE FIELD recipe ON TABLE RecipeContainsIngredients TYPE record<Recipe>;
DEFINE FIELD ingredient ON TABLE RecipeContainsIngredients TYPE record<Ingredient>;
DEFINE TABLE SupplierContainsIngredients SCHEMALESS;
DEFINE FIELD delivery_cost ON TABLE SupplierContainsIngredients TYPE float;
DEFINE FIELD delivery_time ON TABLE SupplierContainsIngredients TYPE int;
DEFINE FIELD supplier ON TABLE SupplierContainsIngredients TYPE record<Supplier>;
DEFINE FIELD ingredient ON TABLE SupplierContainsIngredients TYPE record<Ingredient>;
DEFINE TABLE OrderContainsIngredients SCHEMALESS;
DEFINE FIELD quantity ON TABLE OrderContainsIngredients TYPE int;
DEFINE FIELD `order` ON TABLE OrderContainsIngredients TYPE record<Order>;
DEFINE FIELD ingredient ON TABLE OrderContainsIngredients TYPE record<Ingredient>;