Subject Areas and Diagrams – Explained
One neat feature of SqlDBM is the ability to segregate and view only certain parts of your database. You do this by use of Subject Areas and Diagrams. Subject Areas and Diagrams are analogous to materialized views in relational databases. So what’s the difference between the two, and how do you use them?
Diagram in Subject Area
Subject area is basically a folder to contain one or more diagrams. Create Subject Areas to cover different aspects of your business needs. Then create multiple specialized diagrams or models in each Subject Area to reflect only those aspects of the Subject Area you are working on.
Think of a Subject Area as a standalone subset of your database, where you want to isolate some section of your database so your can focus/work/visualize only that section of your database. For example, say you have different tables to store details of both active and inactive customers in your database. And you want to restrict you current database view to only see active customers. How would you do this? Simple, create a Subject Area, and Sqldbm automatically creates a default diagram within that Subject Area. That is our first factoid – a diagram always exists within a Subject Area. Our 2nd factoid is that Sqldbm always auto-creates one diagram every time you create a Subject Area, though you can add as many extra diagrams as you wish to a Subject Area.
So back to our Active vs. inactive customers scenario. How do we create a Subject Area and the diagrams to depict this scenario? Here are the steps to do this:
- First, create a Subject Area by right-clicking on ‘Subject Areas’ in the Diagrams View and selecting ‘Add Subject Area’.
- Next, rename your Subject Area in the DIAGRAM PROPERTIES section on the far-right of the Sqldbm interface.
- Remember, the first diagram in your Subject Area will be created automatically. You can also select this first diagram and use the DIAGRAM PROPERTIES section to rename it. To add a new diagram, simply right-click the Subject Area and select ‘Add Diagram’. See screenshot below:
- Next, with your Subject Area selected, add the tables you require into each diagram. To add a table, first ensure that you have selected the relevant Subject Area and Diagram that you want – as highlighted in the screenshot below. Then right-click any empty part of the diagram and select ‘Add Table’. In the screenshot below, we already have two tables named ‘Active_Customers_a’ and ‘Active_Customers_b’ in the ‘Active Customers’ diagram, which is in the ‘Customers_only’ Subject Area, and we are now adding a new table to the 2 already created.
And that’s it! As you can see, it is a simple way to view only a subset of your database. A few more points to note about Subject Areas:
- Remember that all tables you create within Subject Areas are still part of your database. Therefore when viewing your entire database in, say, the Database Explorer view, you will see a list of ALL your tables listed, regardless of whether they are in a Subject Area or not. See example screenshot below. Note that in this screenshot, although we have highlighted the ‘Customers_only’ Subject Area, we are in the Database Explorer view mode, which means the list of tables shown will include ALL the tables in our database.
- Also keep in mind that unlike the Database Explorer view, the ‘Root’ diagram will not necessarily contain all the tables you have added in other Subject Areas. The ‘Root’ diagram is simply the default first diagram created when you first start using SqlDBM. But it is just a diagram like any other, except of course that it does not reside within a Subject Area. Therefore, if you want subsequently create a Subject Area and want to add a table from it to the Root diagram, you must do so manually – the table will not be included in the Root diagram by default. For example, in the screenshot below, note that the table named ‘Active_Customers_a’, which is part of the ‘Customers_only’ Subject Area, has been manually added to the Root diagram. But table ‘Active_Customers_b’, which is also part of the same Subject Area, has been left out.
- Finally, to filter by Subject Area or Diagram, use either the SqlDBM drop-down selector, or the icons at the bottom-left of the SqlDBM interface. See these highlighted in screenshot below: