Subject areas
Models are usually quite big. They're full of entities, associations, relationships, and all these things together make it really easy for a database architect to get lost. Luckily, when you design your database using Vertabelo, you can use subject areas to help you anytime you feel overwhelmed by the amount of a model's elements. Thanks to subject areas, we can:
- Increase the model's readability.
- Group model's elements according to their functions.
- Make it easy to navigate through the model.
- Simplify searching for elements.
- Use the same entity several times in one model.
Sounds good, doesn't it? Let's learn how to use them.
Adding a new subject area
We're going to use subject areas on a model of a simple shop. Our aim is to create two areas – Purchase and Product and put all related elements into them.
To add a new area either click this button on your toolbox or press s
key on your keyboard.
Click and hold the left mouse button and drag your cursor to draw a box around all of the elements you want to include in your subject area.
In properties, you can change the area's name and give it a unique look by changing colors or a line's style.
Now, we've got two areas – Purchase and Product, just as we desired. Let's go to Model Structure to see what has changed there.
Subject areas in Model Structure
If you want to change something in just one entity, you don't have to go through all the entities or search for it in your whole model any more. All you have to do now is to choose the right subject area and then proceed to your entity directly. Obviously, you can do the same with relationships.
Right-click on the area's name in Model Structure to access some additional features like finding the area in a diagram or adding new elements to it.
By doing the same with an element, you can find it in the diagram or delete a entity shortcut. What is a entity shortcut? You will find out soon, but using it in that case will just delete the entity.
Overlapping subject areas
What's more, areas can overlap. Let's say we want to have a Client area with the purchase entity inside, which is already in the Purchase area.
As you can see in the image below, it's not a problem at all. Now we've got the purchase entity in both areas, what is absolutely fine.
But what if we are using thousands of entities and millions of relationships and overlapping is not enough? What if a entity is used for completely different functionalities and we want to be able to access it in only one exact context? The answer is: shortcuts.
Shortcuts
Let's try to do exactly the same thing like we did above – creating two different subject areas containing the purchase entity, but now using shortcuts. Begin by adding one shortcut for client, one for purchase_item and two for purchase. This can be done by clicking the Add shortcut entity under the right-click menu.
However, the more convenient way to do this is to simply drag the entity from the Model Structure panel to the diagram area.
Shortcuts are automatically enumerated in their names.
Let's create subject areas containing adequate shortcuts, just like we've done before. Note that the shortcuts' names have changed and now they contain names of the subject areas they belong to.
To get the relationships between these entities back, Control-click all of the entities in the area and then click Show all relationships.
Now, in each area we've got only the relationships relevant to it, which makes our model much more readable, especially in the case of entities involved in multiple relationships.
Shortcuts in the model are distinguished by having a dashed line as a border. Adding any shortcut to a entity changes the entity's initial representation into a shortcut too.
If you click on a shortcut in the Properties pane, you will see that it's only a representation of the entity already existing in our database and nothing more. Therefore, any change to the entity's properties will affect all shortcuts in the model.
Shortcuts in Model Structure
Note that areas in Model Structure look exactly the same as they did when we used overlapping instead of shortcuts.