Entity Relationship Diagrams

Overview

Entity Relationship Diagrams (ERDs) define the structure of the data in your application. "Entities" are displayed as tables and represent the "things" in the world that you want to show as data.

Opening and Creating ERDs

  • On your application's home page, click  ERD to list the existing ERDs.
    • Alternatively, click  ERD from the header bar. 
  • To create a new ERD, click the  Add New button.
  • To open an existing ERD, double-click it.

ERD Layout

Here is a simplified view of the ERD:

 More Details
  1. Toolbar: This contains ERD-specific options to add data to the ERD and move tables on the canvas.
  2. Repository: On the toolbar, click  Table to list all tables in the Repository on the right. These can be dragged and dropped onto the canvas.
  3. Canvas: This is where you create and modify your ERD.
  4. Table: This is represented as a box, containing a list of all of the attributes within the data and their associated data type (e.g. string). 
  5. Relationship: This is represented as a line connecting the tables.
  6. Options: View the data in the table by clicking  or show all table options by clicking .

Tables

A table is where your data is stored for your application. Click on the image below to enlarge it.

Attributes

Attributes represent the different pieces of data recorded in the table, and can be thought of as column headers on a spreadsheet.

  • Attributes are configured with a data type (e.g. string, integer, true/false) and properties. To change these, click on the attribute's name. See Understanding Data Types.

Primary Keys

Primary Keys are special attributes which uniquely identify each record. 

  • When you create a new table, PhixFlow adds an attribute called UID (Unique IDentifier) and configures it as follows:

    • the table's Primary Key
    • an integer
    • automatically creates a unique number for every record in the table
  • If your data already has a unique attribute, you can use this as the Primary Key by right-clicking and selecting Make Primary Key
    • On the example image above, the Employees table has the attribute EmployeeID as the Primary Key. This is because employees may have the same first and/or surname, so these attributes cannot be guaranteed to be unique and therefore cannot be a Primary Key.

Secondary Keys (PhixFlow version 11.3+)

Secondary keys are optional keys that index records and do not have to be unique.  

When you create a relationship, one attribute in the relation must be either a Primary Key or a Secondary Key.

Foreign Keys

Foreign Keys are attributes in one table that relate to the Primary or Secondary Key in another table.

  • Foreign Keys must have the same data type as the corresponding Primary Key or Secondary Key. For example, both must be strings and of the same length.

When a relationship is created by dragging a Primary Key or Secondary Key from one table onto the attribute of another table, PhixFlow sets this attribute to be a Foreign Key.

Display Names 

Display Names are special attributes which are displayed instead of a Foreign Key, as they make more sense to a human.

  • When you create a new table, PhixFlow adds an attribute called Name and configures it as the Display Name.
    • This is then shown in place of the Foreign Key when displayed on a screen as part of a relational view, see Using Relational Views. Display Names do not need to be unique and should be user-friendly.
  • If your data already has an attribute you want to use as the Display Name, right-click it and select Make Display Name

Validation

Validation is applied to table attributes and determines the criteria an attribute must satisfy in order to be considered valid. For example, the attribute is mandatory, must contain a minimum number of characters or must adhere to a specific pattern. Validation, added to a table attribute, will be applied wherever that attribute is updated, such as when saving data on an input screen. See Table Attribute Validation.

Indexing

Indexes are applied to attributes on a table and help improve the speed of data retrieval when handling large data sets. See Indexing.

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. See Creating Dashboards and Reports.

A line connects the Primary Key or Secondary Key of one table to a Foreign Key in a different table and represents a relationship. See Relationship Click on the image below to enlarge it.

One-to-Many and Many-to-One

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. Click on the image below to enlarge it.


Many-to-Many 

Many-to-many relationship can be supported with an intermediate table.

 Click here to see more

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 above, many students take many courses, and so a many-to-many relationship is created using the intermediate table, CourseAttendee.

Working in an ERD

You can add tables in an ERD manually. See Adding Content to an ERD.

  • Create a new table by dragging  Table from the toolbar onto the canvas.
  • Add an Excel spreadsheet or CSV file by dragging it onto the canvas. PhixFlow imports the data and creates a new table. Note, the expected format is the header is the first row followed by the data. If your data is in a different format, this is supported, see Importing Data from Excel (Advanced).
  • Add an existing table by clicking  Table in the toolbar. The available tables are listed in the Repository and can be dragged onto the canvas. 
  • If you have data in an external source such as database and wish to add this data, it will first need to be imported. See Importing Data.

View Table Data 

To view the data in a table, click  from the header as illustrated below. Different views can be created and will also be made available from this option, see Creating Dashboards and Reports.

Create a Screen from a Table

Select  from the table options and click Create Screen. See Creating a Screen from an ERD Table.

Multiple ERDs

The same table can appear on multiple ERDs.

ERD Example

 Display worked example

The below example is an ERD for a school.

A school has entities, for example: departments (SchoolDept), teachers, students, class rooms, and so on. All these entities are represented as tables. The lines connecting the tables show the relationships between them. We can see from this diagram that a Departments (SchoolDept) has many Classrooms and Teachers.

In the Teacher table, Department is the Foreign Key and contains the same data type as the Primary Key, UID, in the SchoolDept table. 

The Foreign Key represents the many side and the Primary Key the one side. This means that SchoolDept.UID is unique and there is only one record containing this unique information. Teacher.Department can have one or more instances of a value of UID. For example, the Maths Department UID could occur 10 times, once for each of the 10 maths teachers.

When you create screens that show data, PhixFlow uses the relationships defined in the ERD to provide options for displaying data from related attributes in the same grid, form, card, graph or chart. This means you only need to store the School DeptID against a teacher to be able to access all of the SchoolDept details. See Displaying Data (Views).

What's Next?

The PhixFlow Fundamentals course provides a practical guide to using PhixFlow, including setting up ERDs. 

Already started PhixFlow Fundamentals?

Return to ERD Fundamentals

Further Reading