In short, a domain '''presents''' selected data field to an audience, i.e. to end-users running reports and designing dashboards.
{{Note|Basic relational database / SQL knowledge is required for creating a domain.}}
== Add a domain ==__NOEDITSECTION__
{{Note|In this tab, only '''tables''' of the database are displayed. If views need to be queried, this can be achieved via derived tables as described in the next section.}}
Once all required tables are selected, click on the next tab, '''Derived Tables'''.
=== Derived Tables ===__NOEDITSECTION__
SELECT accident_guid, extract(year from dateofaccident) as year_of_accidnet FROM accident
</pre>
Enter this query in the '''Query (required)''' pane, give it a name in the '''Query ID (required)''' field, and click on '''Run Query'''. If the query runs successfully on the database specified for the domain, the attributes returned by the database are displayed. Select both fields and click on '''Select Table'''. The derived table now appears in the left-hand pane, under '''Available objects'''. The symbol next to the name suggests that it is a ''derived'' table, as opposed to a ''normal'' database table.
[[File:MINT_domain_designer_derived_tables.png|center|900px]]
Once all required derived tables are selected, click on the next tab, '''Joins'''.
=== Joins ===__NOEDITSECTION__
In the example mentioned above, three tables had been selected/created, two ''normal'' ones and one ''derived''. As for any database query, when data from several tables is combined, these tables need to be put in context, i.e. it has to be specified how these tables can be combined. In the above example, the following joins need to be created:
* Join between '''accident''' and '''accdeviceinfo''' on the attribute '''accident_guid''' present in both tables.
* Join between '''accident''' and the derived table '''year_of_accident''', also on the attribute '''accident_guid''' present in both tables.
In the Domain Designer, these joins can be created graphically, i.e. they do not have to be written in SQL. In the '''Join''' section of the Designer, the '''Left''' and '''Right''' tables can be expanded in order to select the attributes for the join. Once both on the left and on the right-hand side the required attributes have been selected, the type of join (inner, left outer, right outer, full outer) has to be specified by clicking on the corresponding symbol.
[[File:MINT_domain_designer_join_types.png|center]]
For the above example, the end result would look as follows:
[[File:MINT_domain_designer_joins.png|center|900px]]
Once all required joins are defined, click on the next tab, '''Calculated Fields'''.
=== Calculated Fields ===__NOEDITSECTION__