Model Customer @sql('select * from customer') {
custkey: INTEGER! @primaryKey
name: VARCHAR
address: VARCHAR
nationkey: INTEGER
phone: VARCHAR
acctbal: REAL
mktsegment: VARCHAR
comment: VARCHAR
orders: Orders[] @relation(OrdersCustomer)
nation: Nation @relation(NationCustomer)
}
Model Orders @sql('select * from orders') {
orderkey: INTEGER! @primaryKey
custkey: INTEGER!
orderstatus: OrderStatus
totalprice: REAL
orderdate: VARCHAR
orderpriority: VARCHAR
clerk: VARCHAR
shippriority: INTEGER
comment: VARCHAR
customer: Customer @relation(OrdersCustomer)
lineitems: Lineitem[] @relation(OrdersLineitem)
}
Model Lineitem @sql('select * from lineitem') {
orderkey: INTEGER
linenumber: INTEGER
orderkey_linenumber: VARCHAR @expr("concat(orderkey, linenumber)") @primaryKey
partkey: INTEGER
suppkey: INTEGER
partkey_suppkey: VARCHAR @expr("concat(partkey, suppkey)")
quantity: REAL
extendedprice: REAL
discount: REAL
tax: REAL
returnflag: VARCHAR
linestatus: VARCHAR
shipdate: VARCHAR
commitdate: VARCHAR
receiptdate: VARCHAR
shipinstruct: VARCHAR
shipmode: VARCHAR
comment: VARCHAR
orders: Orders @relation(OrdersLineitem)
partsupp: PartSupp @relation(PartSuppLineitem)
supplier: Supplier @relation(SupplierLineitem)
part: Part @relation(PartLineitem)
}
Model Part @sql('select * from part') {
partkey: INTEGER! @primaryKey
name: VARCHAR
mfgr: VARCHAR
brand: VARCHAR
type: VARCHAR
size: INTEGER
container: VARCHAR
retailprice: REAL
comment: VARCHAR
partsupps: PartSupp[] @relation(PartSuppPart)
lineitems: Lineitem[] @relation(PartLineitem)
}
Model Supplier @sql('select * from supplier') {
suppkey: INTEGER! @primaryKey
name: VARCHAR
address: VARCHAR
nationkey: INTEGER
phone: VARCHAR
acctbal: REAL
comment: VARCHAR
partsupps: PartSupp[] @relation(PartSuppSupplier)
lineitems: Lineitem[] @relation(SupplierLineitem)
}
Model PartSupp @sql('select * from partsupp') {
partkey: INTEGER
suppkey: INTEGER
partkey_suppkey: VARCHAR @expr("concat(partkey, suppkey)") @primaryKey
availqty: INTEGER
supplycost: REAL
comment: VARCHAR
part: Part @relation(PartSuppPart)
supplier: Supplier @relation(PartSuppSupplier)
}
Model Nation @sql('select * from nation') {
nationkey: INTEGER! @primaryKey
name: VARCHAR
regionkey: INTEGER
comment: VARCHAR
region: Region @relation(NationRegion)
}
Model Region @sql('select * from region') {
regionkey: INTEGER! @primaryKey
name: VARCHAR
comment: VARCHAR
nations: Nation[] @relation(NationRegion)
}
enum OrderStatus {
FULFILLED: 'F',
PROCESSING: 'P',
OPEN: 'O'
}
Relation OrdersLineitem @condition(Orders.orderkey = Lineitem.orderkey) @desc("Orders of Lineitem") {
models: [Orders, Lineitem]
type: "ONE_TO_MANY"
}
Relation OrdersCustomer @condition(Orders.custkey = Customer.custkey) @desc("Orders of Customer") {
models: [Orders, Customer]
type: "MANY_TO_ONE"
}
Relation PartSuppPart @condition(Part.partkey = PartSupp.partkey) @desc("PartSupp of Part") {
models: [Part, PartSupp]
type: "ONE_TO_MANY"
}
Relation PartSuppSupplier @condition(Supplier.suppkey = PartSupp.suppkey) @desc("PartSupp of Supplier") {
models: [Supplier, PartSupp]
type: "ONE_TO_MANY"
}
Relation NationRegion @condition(Nation.regionkey = Region.regionkey) @desc("Nations of Region") {
models: [Nation, Region]
type: "MANY_TO_ONE"
}
Relation NationCustomer @condition(Nation.nationkey = Customer.nationkey) @desc("Nations of Customer") {
models: [Nation, Customer]
type: "ONE_TO_MANY"
}
Relation PartSuppLineitem @condition(PartSupp.partkey_suppkey = Lineitem.partkey_suppkey) @desc("PartSupp of Lineitem") {
models: [PartSupp, Lineitem]
type: "ONE_TO_MANY"
}
Relation PartLineitem @condition(Part.partkey = Lineitem.partkey) @desc("Part of Lineitem") {
models: [Part, Lineitem]
type: "ONE_TO_MANY"
}
Relation SupplierLineitem @condition(Supplier.suppkey = Lineitem.suppkey) @desc("Supplier of Lineitem") {
models: [Supplier, Lineitem]
type: "ONE_TO_MANY"
}