Find out how to add a table to your ER Diagram in Vertabelo.
A table in a database is where some data about something is stored and organized logically in rows and columns. The columns in a table represent data and its types. For instance, a database for an e-commerce website would likely have a client
table where data about each client is stored. It will very likely have a name
column of type string
.
As you design your database model, you have to add and delete tables often. For instance, if you have a physical model for an e-commerce website, you might want to add new tables to represent other related data objects such as purchase
, product
, and others.
There are two main ways to add a table in Vertabelo: by using the toolbar or by using the dropdown icon in the Model Structure panel.
If you need to, you can refresh your memory on why ER diagrams are needed.
Note that, for the purpose of demonstration, we will use an example BigQuery database for an e-commerce website. Some options may or may not be present for you depending on the exact type of database used.
Adding Tables Using the Toolbar
First, direct your attention to the toolbar in the upper-left corner of the screen.
Next, click the highlighted button as shown in the picture. Then, click on the spot where you want to add the table.
Adding Tables via Model Structure Panel
The other method consists of clicking on “Tables” in the Model Structure panel on the left side of the screen. Then, select the “Add table” option from the drop-down menu.
After clicking this option, a table will show up at the center of your workspace.
Formatting Tables
Once you have created the tables, the next step is to format these tables to your liking. You can read this guide on aligning elements for tables in Vertabelo to start.
Renaming Tables
To rename a table, simply edit the Name field under “Table Properties” on the right side of your screen.
Adding Columns to Tables
To add attributes, click the “+Add column” button in the Columns section. To rename a column, simply type in your desired name in the Name field.
Then, you can either type in the column Type or click on the gear icon to pick a type from the list. Here's an example list – it's different for every database you select for the model:
The N checkbox means “Nullable.” Depending on the exact database used, you might also find a PK checkbox beside the N checkbox. PK stands for “Primary Key.”
Adding Comments, Default Values, and Check Expressions
Another nifty feature is that you can add comments to the table and/or columns right in the model. To do so, simply fill out the Comment text box for the table or click the down button to show the Comment text box for the column.
You can also set the default value and the check expression by typing in the Default value and/or the Check expression text box under the Comment text box like this:
Copying Tables
To create a copy of a table, you can press the copy and paste buttons as highlighted in the image, or use the standard Ctrl+C/Ctrl+V or Cmd+C/Cmd+V shortcuts.
You will have an additional table that looks like this:
All the details such as attributes and comments will carry over to the copy of the table.
Using the SQL Preview
You can click the SQL preview button to preview the part of the script that generates the table. To get the whole script, click on the SQL button in the main toolbar.
When you click the button, the script will look like this:
Additional Fields
As an aside, you can fine tune a few aspects in the following sections in the Table Properties panel:
- Primary key: lets you check and define the primary key. You can also define a multicolumn primary key.
- Alternate (unique) keys: lets you restrict some columns to be unique, e.g., a combination of first name, last name, and date of birth.
- Indexes: can boost your
SELECT
query times if you often search by a certain column, but remember that they slow downINSERT
andUPDATE
operations. - Checks: lets you define conditions to be checked before inserting or updating the data in the database.
- Additional SQL scripts: allows you to put custom logic to be executed before or after creating the table.
- Additional properties: here, you can find options that are usually specific to the database engine.
- Format: lets you change the colors of the table, so that it's easier to move your model around.
Adding Tables in Your ER Diagram: Easy and Intuitive
Adding tables and tweaking them in your ER diagram is easy and intuitive with Vertabelo. You can rename tables, add columns, add comments, set default values, specify check expressions, preview SQL scripts, and create copies of tables. All the functionalities you need are available in the main toolbar or in the left- or right-hand panels. If they are not visible, you may need to unhide them using these buttons from the main toolbar:
If you want to read something more advanced, you can check out how to generate a migration script between any two versions of your Vertabelo model.