Skip to main content

Table groups

TableGroups: membership, color, note as a setting, note as a body field, custom properties, and a group holding schema-qualified tables.

Covers: TableGroup with color, note as a setting and as a body Note:, custom properties, schema-qualified members, a group without settings

05-table-groups.dbml
05-table-groups.dbmle_commerce Contains tables that are related to e-commerce systeme_commercecatalog Catalog and ordering. Orders reference products directly; there is no cart table. catalogbilling_groupbilling_grouppeoplepeoplepublic.merchants.id < public.products.merchant_idpublic.products.id < public.orders.product_idpublic.countries.code < public.users.country_codepublic.orders.id < billing.invoices.order_idbilling.invoices.id < billing.invoice_lines.invoice_idmerchantsmerchantsid integer · primary keyidintegername varcharnamevarcharcountriescountriescode char(2) · primary keycodechar(2)name varcharnamevarcharproductsproductsid integer · primary keyidintegermerchant_id integer · foreign keymerchant_idintegername varcharnamevarcharordersordersid integer · primary keyidintegerproduct_id integer · foreign keyproduct_idintegerquantity integerquantityintegerusersusersid integer · primary keyidintegercountry_code char(2) · foreign keycountry_codechar(2)billing.invoicesbilling.invoicesid integer · primary keyidintegerorder_id integer · foreign keyorder_idintegertotal numerictotalnumericbilling.invoice_linesbilling.invoice_linesid integer · primary keyidintegerinvoice_id integer · foreign keyinvoice_idintegeramount numericamountnumeric

Source​

examples/05-table-groups.dbml
examples/05-table-groups.dbml
// TableGroups: membership, color, note as a setting, note as a body field,
// custom properties, and a group holding schema-qualified tables.

Table merchants {
id integer [pk]
name varchar
}

Table countries {
code char(2) [pk]
name varchar
}

Table products {
id integer [pk]
merchant_id integer [ref: > merchants.id]
name varchar
}

Table orders {
id integer [pk]
product_id integer [ref: > products.id]
quantity integer
}

Table users {
id integer [pk]
country_code char(2) [ref: > countries.code]
}

Table billing.invoices {
id integer [pk]
order_id integer [ref: > orders.id]
total numeric
}

Table billing.invoice_lines {
id integer [pk]
invoice_id integer [ref: > billing.invoices.id]
amount numeric
}

TableGroup e_commerce [color: #3498DB, note: 'Contains tables that are related to e-commerce system'] {
merchants
countries
}

TableGroup catalog [color: #79AD51] {
products
orders

Note: '''
Catalog and ordering.
Orders reference products directly; there is no cart table.
'''
}

TableGroup billing_group [color: #e67e22, team: 'finance', reviewed: true] {
billing.invoices
billing.invoice_lines
}

// A group with no settings at all.
TableGroup people {
users
}