Understanding Table Relationships
Relationships Between Tables
Tables in PhixFlow are relational, which means that information in one table can be related to information in another table. Data can then be accessed in many different views without requiring duplication. A line connects the Primary Key or Secondary Key of one table to a Foreign Key in a different table and represents a Relationship. The relationships supported in PhixFlow are:
One-to-Many and Many-to-One Relationships
The relationship line between a Primary Key or Secondary Key and Foreign Key represents a one-to-many relationship. In the below example, one teacher runs many courses.
A many-to-one relationship is implied when you read a relationship in the opposite direction. In the below example, many courses are run by one teacher.
Many-to-Many Relationships
Many-to-many relationship can be supported with an intermediate table.
A many-to-many relationship is created when there is an intermediate table with a Foreign Key from each of the related tables. In the example used below, many students take many courses, and so a many-to-many relationship is created using the intermediate table, Schools_Course_Attendees.
Multi-Hop Relationships
Multi-hop relationships are relationships between tables without a direct relationship. PhixFlow supports multi-hop relationships to a distance of 4 hops. In the example ERD below, the relationship distance between the Buildings and Bookings table is 2 hops, and between the Buildings and Departments table is 4 hops.
Creating Multi-Hop Views and SubViews
When a View is created on a table, SubViews are created automatically.
SubViews can be seen in Attribute Source section on the View and represent one table linked to another. If more attributes are added to the main View and there's already an appropriate SubView, they will be added automatically to the SubView, otherwise another SubView will be created.
Attributes can also be added from the Available Attributes window directly onto the Attribute Source section.
Modifying SubViews
- Access the SubView properties from the View properties → Attribute Source section → double-click on a SubView name
- SubViews can be copied by right-clicking on the SubView in the Attribute Source section and choosing Duplicate SubView
- Duplicating a SubView does not copy the attributes, just the source and target tables are copied
If required, a Default Filter can be applied to the SubView and will apply to all attributes on the SubView.
Filters for specific attributes can also be applied but the attribute must be aggregate. This is set by double-clicking the attribute name in the View Attributes section of the View to choose an Aggregate Function, then apply a Filter.
Further Reading
- For a multi-hop worked example, see Multi-Hop Worked Example
- Relationship
- Creating Dashboards and Reports (Charts and Graphs)