LinkORB Engineering

How to use the schema tool - a step-by-step guide

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 authorized users can access the schema tool within Team 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 favorite meme-inspired items, adding a touch of humor 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.

FieldEnter / Select this valueOptional / Mandatory
Namee-commerce_[YOUR INITIALS]Mandatory
Read roleROLE_USERGROUP:SCHEMATA-TEAMMandatory
DescriptionDocuments MemeFactory's databaseOptional

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.

FieldEnter / select this valueOptional / Mandatory
NameOrdersMandatory
Doc StatusDRAFTOptional
DescriptionStores customer ordersOptional

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.

FieldEnter / Select this valueOptional / Mandatory
Nameorder_numberMandatory
TypestringMandatory
NullableyesMandatory
Lengthstring(128)Mandatory
Doc statusREVIEWMandatory

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.

  1. Create an XML document in the text editor of your choice called e-commerce.xml and 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>
  1. Save the file.

This code is our fully fleshed-out schema that contains all the tables and columns we will work with going forward.

  1. From the e-commerce schema 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.

  1. From the Orders table page, open customer_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.
  1. For Relation table, select Customers.
  2. 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 capitalized 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 id column of the customer table has a one-to-one (foreign key) relationship with the customer_id column of the purchases table, do not document that relationship in the customer tableā€™s description like the following example does:

    customers - Customer details. customer.id uses purchases.customer_id as its foreign key.

    Instead, remove the second sentence:

    customer - Customer details.

    Then, set the customer.id columnā€™s Relation table field to purchases and the Relation column field to customer_id.

  • To write a meaningful description, consider the userā€™s possible questions. For example, for an image_size column, 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:

  1. Contact the SME to review INPUT items.

  2. The SME updates the Doc Status to DRAFT after they have added their input.

  3. Review the DRAFT items and make updates where necessary.

  4. Change the Doc Status of updated items to REVIEW.

  5. Consult the project lead for feedback once a schema has been documented thoroughly and is in REVIEW status.

  6. Change the Doc Status to DRAFT if 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. :::ng database schemas u