This page is for application designers who want define the data that will back the application. It explains how to draw an ERD and setup its properties.
Overview
Use an ERD to define the structure of the data that backs your application. For an introduction to ERD concepts and why ERDs are important, see Understanding ERDs.
The process for creating an ERD is slightly different depending on whether or not you have already created streams in PhixFlow. The following stream summarises the different ways you can add streams to an ERD, depending on your starting point. (See the sections below for details of how to add streams and relationships.)
How to Define an ERD
Open an Existing ERD
In the repository, find ERD.
- Either right-click on an ERD name and select Display.
- Or double-click the ERD name to open the properties. In the properties toolbar, click the Display icon.
Create a New ERD
- In the repository, find ERD. Right-click to display the context menu, and select Add New
Enter a name for your ERD, and a description then click OK.
When you are creating streams, choose a name that reflects the entity your stream represents.
PhixFlow opens a new ERD canvas on the left with a toolbar at the top. Hover your mouse pointer over toolbar icons to display a tooltip.
Add an Existing Stream
- In the toolbar, click List Tables.
- PhixFlow filters the repository to show the list of streams available in this application.
- Drag a stream from the repository onto the ERD canvas.
Create a New Stream
- Drag Create New Table from the toolbar into the diagram.
- In the pop-up, enter a name, for example "Customer", and click .
- PhixFlow opens the properties tab for the new stream on the right and adds the stream to the canvas.
The header displays the name entered in step 2. PhixFlow automatically adds 2 attributes:
- UID - PhixFlow requires a unique identifier and primary key for each stream.
- Name - PhixFlow sets the Name attribute to be the display name. In data grids and forms etc. PhixFlow uses this attribute to provide a user-friendly name, rather than a numeric identifier. Optionally, change the attribute name.
- To add attributes to the stream:
- In the stream, click Create New. PhixFlow opens the attribute properties on the right, with the default settings of:
- Type = String
- Length = 50 characters.
- In the properties, enter the Name and select appropriate type properties, such as Date or Integer; see Attribute. The following data types have additional properties:
- For String add Length
- For Integer add Precision
- For Decimal add Significant Figures and Decimal Places
- Click OK to save the attribute properties.
- In the stream, click Create New. PhixFlow opens the attribute properties on the right, with the default settings of:
- PhixFlow adds the attribute to the stream in the ERD.
Create Relationships
In an ERD you can create a one-to-many relationship between a primary key in one stream with an attribute in another stream. For relationship concepts, see Understanding ERDs.
To create a relationship, click-drag from one attribute to another.
See the stream below for the relationships that can be created between attributes.
Drag | Relationship line | |
---|---|---|
From stream1 | To stream2 | |
primary key | attribute | stream1.primarykey → stream2.attribute |
attribute | primary key | stream2.primarykey → stream1.attribute |
attribute | attribute | if stream1 has no primary key: PhixFlow makes the stream1.attribute the primary key if stream 1 has a primary key: the relationship is from stream1.primarykey instead of from stream1.attribute. |
PhixFlow cannot create a relationship between your selected attributes if your selected foreign key attribute:
- is already a foreign key to a different primary key.
- has a different Data Type and type properties to the primary key.
In these cases, PhixFlow reports an error: Related attributes must have the same type and length. This type/length is different.
If this happens, you can:
- create a new attribute to be the foreign key
- change the foreign key attributes to match the primary key, provided there is no data in the stream
- create the relationship with a different attribute.
To change the data type properties, In the ERD, click on an attribute to open its properties.
If you have created several ERDs to define the data structure that your application requires, then each ERD is a view onto a part of the full data structure.
Show Relationships From Other ERDs
If you have created several ERDs to define the data structure that your application requires, then each ERD is a view onto a part of the full data structure.
If a stream appears on more than one ERD it may have relationships with streams that are not visible in your current ERD. To see other related streams, right-click a stream to show the context menu and select:
- Show many-to-one relations
- Show one-to-many relations
PhixFlow adds the related streams to your ERD.
To keep the related streams in your ERD, in the toolbar, click Save.
To remove the related streams from your ERD, in the toolbar, click Refresh.
Saving ERDs
Changes to streams, attributes and relationships are automatically saved. However, to keep any changes you make to the layout of a diagram, such as moving streams or adding angle points to relationships, remember to click Save in the toolbar. PhixFlow notifies you if there are unsaved changes when you attempt to close an ERD.
Accessing Properties
You can set properties for all the items in an ERD. To access properties:
- for the ERD: in the canvas toolbar click Properties
- for a stream: in the ERD, click on the stream header or right-click to open the pop-up menu and select Configure
- for an attribute: in the stream, click on an attribute
- for a relationship: in the ERD, click on the relationship line. For relationships you can only add or change the description.
PhixFlow opens the properties panel on the right.
Rearranging ERDs
To move streams around in the ERD, click on the header and drag the stream. There are also Align options in the toolbar that you can use to line up or distribute selected streams.
If you want to highlight the relationships that affect a stream, click the stream to select it. The following screenshot shows the Teacher stream is selected.
- Blue lines indicate relationships to a foreign key in the selected stream
- Green lines indicate relationships from the primary key in the selected stream.
If a stream has a lot of attributes that you do not need to see, collapse the list to show only the stream's primary and foreign keys.
- Either right-click on a stream and select Hide attributes or Show attributes
- Or double-click on the stream header.
To select multiple streams, draw a square around them.
By default, relationships are straight lines, but you can change them to have angles.
- Click on a relationship line to add an angle point, which appears as a blue dot; see the screenshot on the left.
- Move the mouse pointer over the blue dot. It changes to a four-way arrow to indicate you can drag.
- Drag the point to the position you require.
To remove an unwanted angle, right-click the blue dot and select Remove Point; see the screenshot on the right.
Hover your mouse pointer over
an angle to see the blue angle point.
Right-click the blue angle point to see the Remove option