At LinkORB, we use the schema tool to document databases that our applications rely on. This guide shows how to collaborate with your team members to document databases like a pro š.
Only authorised users can access the schema tool within HQ š, and access to particular schemas is granted case-by-case. Request access to specific schemas by contacting your team lead.
Before documenting database schemas using the Schema tool, refer to rules to learn how to write informative descriptions.
Letās explore the different components of the schema tool by creating and editing a schema for a fake e-commerce site called MemeFactory that sells a wide range of āmeme-printedā products such as tee-shirts, coffee mugs, calendars, magnets, wall art, stationery, and greeting cards. Customers can browse and purchase their favourite meme-inspired items, adding a touch of humour and sarcasm to their lives. š
The database associated with this web application is named e-commerce (since MemeFactory is an e-commerce site).
The name of an application and its associated database name may differ. For example, the plaza database stores data for the zwangerenportaal application.
Add a new schema
Letās create a schema for the e-commerce database.
Add a schema from the Schemas page and fill in the details using the sample data below.
| Field | Enter / Select this value | Optional / Mandatory |
|---|---|---|
| Name | e-commerce_[YOUR INITIALS] | Mandatory |
| Read role | ROLE_USERGROUP:SCHEMATA-TEAM | Mandatory |
| Description | Documents MemeFactory's database | Optional |
Append your initials to the schema name as shown in the sample data. For example, e-commerce_MW reduces the chance of a conflict with another userās schema š.
Add a table to the schema
Right now, our schema looks mighty empty š¤. Ah! That is because we have not added any tables or columns. Letās add a new Orders table to the schema!
Add a new table from the new e-commerce schema page and fill in the details using the sample data below.
| Field | Enter / select this value | Optional / Mandatory |
|---|---|---|
| Name | Orders | Mandatory |
| Doc Status | DRAFT | Optional |
| Description | Stores customer orders | Optional |
For future reference, you may skip the optional fields based on your requirements š.
Add a column to the table
Our new Orders table needs some columns. Letās add a new order_number column that specifies how much meme merch was sold per order.
Add a new column from the new Orders table page and fill in the details using the sample data below.
| Field | Enter / Select this value | Optional / Mandatory |
|---|---|---|
| Name | order_number | Mandatory |
| Type | string | Mandatory |
| Nullable | yes | Mandatory |
| Length | string(128) | Mandatory |
| Doc status | REVIEW | Mandatory |
Edit columns
Try to figure out how to edit the order_number column and update the length from string(128) to string(32).
Import a schema
You may have noticed that adding tables and columns can be a bit laborious š«. But donāt worry! Fortunately, you also have the option to import a schema in either .csv or .xml format.
XML schemas define tables and columns using XML tags, as the following template shows:
<table>
<column/>
<column/>
<column/>
</table>
Letās import a completed e-commerce schema that includes all the columns and tables we need to complete the rest of the steps.
- Create an XML document in the text editor of your choice called
e-commerce.xmland paste the following code into it:
<?xml version="1.0"?>
<schema>
<table name="Customers" docStatus="INPUT" label="" primaryKeyColumn="customer_id">
<column name="customer_id" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="name" type="string" docStatus="DRAFT" notnull="false"/>
<column name="email" type="string" docStatus="DRAFT" notnull="false"/>
<column name="address" type="string" docStatus="DRAFT" notnull="false"/>
</table>
<table name="Products" docStatus="DRAFT" label="" primaryKeyColumn="product_id">
<column name="product_id" type="integer" comment="PK of the products table." docStatus="REVIEW" notnull="false"/>
<column name="order_item_id" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="order_id" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="quantity" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="price" type="integer" docStatus="DRAFT" notnull="false"/>
</table>
<table name="Orders" docStatus="REVIEW" label="" primaryKeyColumn="order_id">
<column name="order_id" type="integer" comment="uniquely identifies each row." docStatus="REVIEW" notnull="false"/>
<column name="order_date" type="integer" comment="date when order is placed." docStatus="DRAFT" notnull="false"/>
<column name="customer_id" type="integer" docStatus="DRAFT" notnull="false" relation="Customers.customer_id"/>
<column name="order_number" type="string" length="32" comment="Provide feedback on this newly added column." docStatus="REVIEW" notnull="false"/>
</table>
<table name="Payments" docStatus="ACTIVE" label="" primaryKeyColumn="payment_id">
<column name="payment_id" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="order_id" type="integer" docStatus="DRAFT" notnull="false"/>
<column name="payment_method" type="string" docStatus="DRAFT" notnull="false"/>
<column name="amount" type="integer" docStatus="DRAFT" notnull="false"/>
</table>
</schema>
- Save the file.
This code is our fully fleshed-out schema that contains all the tables and columns we will work with going forward.
- From the
e-commerceschema page, import the XML schema. You may leave the Upload from Beginning/scratch? ticked.
And voilĆ ! š„³
You now know how to import schema tables and columns in bulk like an efficient developer š¤.
In addition to importing schemas, you may also export them to share with others.
Give the table a primary key
If you view the Orders table, youāll notice we have a few more columns after we imported the XML schema. But something was left out of the XML schema file ā our table needs a primary key to identify each order.
Edit the Orders table and select order_id from the Primary Key Column drop-down.
If you look at the table columns again, youāll notice an asterisk * next to the order_id column to indicate it is the primary key for the Orders table.
Now each order placed by customers has an order_id.
Add foreign keys
A foreign key is a column or group of columns in a relational database table that links data in two tables. You can add foreign keys to a table using the schema tool.
- From the
Orderstable page, opencustomer_id.
The Relational table and Relational column fields specify foreign keys:
- The Relational table field refers to the table that contains the column you wish to use as the foreign key.
- The Relational column field refers to the column belonging to the relational table you wish to use as the foreign key.
- For Relation table, select
Customers. - For Relation column, select
customer_id.
The Orders table now uses the customer_id as its foreign key š«.
Tag use cases
Tags are optional but can be helpful. They are usually applied to large databases like onatal, orfeus, and mosos, to name a few. Donāt use tags for small databases like upr. However, itās okay to tag plaza PII and subsystems.
Click Tags Types from a schema page to view and create new tags.
Letās look at a few use cases for tags:
-
Add tags to PII fields to generate input for compliance docs (LinkORB must report which fields it processes and why).
-
Add tags to fields to be anonymized, stripped, or shuffled before they are sent to analytics databases.
-
Add tags to application subsystems/components to quickly understand a limited set of tables and columns.
Tag types are schema-level, and you cannot reuse them across schemas.
Best practices when writing descriptions
-
Use short descriptions for schemas, tables, and columns. Descriptions do not need to be complete sentences.
-
Start each sentence with a capitalised word and end each sentence with a period since descriptions may require multiple sentences.
-
There is no need to acknowledge that you are describing a schema, table, or column or that it contains something (since that is obvious). So, remove phrases/words like:
- this schema/table/column
- contains
- stores
- holds
For example, instead of saying:
file_version- Table that contains file and image metadata.Focus on what data it stores:
file_version- File and image metadata. -
Provide additional information in a tableās description only if such information is relevant to the whole table. Move all column-specific information to the Comment field of the affected column(s).
-
Avoid using a columnās Comment section to describe relationships. Instead, document relationships using the Relation fields.
For example, if the
idcolumn of thecustomertable has a one-to-one (foreign key) relationship with thecustomer_idcolumn of thepurchasestable, do not document that relationship in thecustomertableās description like the following example does:customers- Customer details.customer.idusespurchases.customer_idas its foreign key.Instead, remove the second sentence:
customer- Customer details.Then, set the
customer.idcolumnās Relation table field topurchasesand the Relation column field tocustomer_id. -
To write a meaningful description, consider the userās possible questions. For example, for an
image_sizecolumn, is the size in bits, bytes, or decimals? Does it represent the original file size or the compressed file size?
Sample review workflow
When working together to document schemas, use the following workflow as guidance:
-
Contact the SME to review
INPUTitems. -
The SME updates the Doc Status to
DRAFTafter they have added their input. -
Review the
DRAFTitems and make updates where necessary. -
Change the Doc Status of updated items to
REVIEW. -
Consult the project lead for feedback once a schema has been documented thoroughly and is in
REVIEWstatus. -
Change the Doc Status to
DRAFTif any items need more work.
Rinse and repeat.
Remember to follow LinkORBās guidelines for getting help and how to conduct effective asynchronous communication while documenting schemas.
A helpful tip for subject matter experts ā from a schema page, you can view tables and columns with a Doc Status of INPUT by clicking INPUT LIST.