atoti.tables.Tables.schema#
- property Tables.schema: object#
Schema of the tables represented as a Mermaid entity relationship diagram.
Each table is represented with 3 or 4 columns:
whether the column’s
default_valueisNone(denoted with nullable) or notthe column
data_type(optional) whether the column is part of the table
keys(denoted with PK) or notthe column
name
Example
>>> table_a = session.create_table( ... "Table a", ... data_types={"foo": "String", "bar": "int"}, ... default_values={"bar": None}, ... ) >>> table_b = session.create_table( ... "Table b", ... data_types={"bar": "int", "baz": "LocalDate"}, ... keys={"bar"}, ... ) >>> table_c = session.create_table( ... "Table c", ... data_types={"foo": "String", "xyz": "double"}, ... keys={"foo", "xyz"}, ... ) >>> table_d = session.create_table( ... "Table d", ... data_types={ ... "foo d": "String", ... "xyz d": "double", ... "abc d": "float", ... }, ... default_values={"abc d": None}, ... keys={"foo d", "xyz d"}, ... ) >>> table_a.join(table_b, table_a["bar"] == table_b["bar"]) >>> table_a.join(table_c, table_a["foo"] == table_c["foo"]) >>> table_c.join( ... table_d, ... (table_c["foo"] == table_d["foo d"]) ... & (table_c["xyz"] == table_d["xyz d"]), ... ) >>> schema = session.tables.schema
erDiagram "Table a" { non-null String "foo" nullable int "bar" } "Table b" { non-null int PK "bar" non-null LocalDate "baz" } "Table c" { non-null String PK "foo" non-null double PK "xyz" } "Table d" { non-null String PK "foo d" non-null double PK "xyz d" nullable float "abc d" } "Table a" }o--o| "Table b" : "bar == bar" "Table a" }o..o{ "Table c" : "foo == foo" "Table c" }o--o| "Table d" : "(foo == “foo d”) & (xyz == “xyz d”)"