2. Importing Data
- Anthony George
- Zoe Baldwin
When creating a screen, it is easier to have data available as it allows you to dynamically create many items and see how the screen will look when populated. For this reason, we will import the data downloaded in Screen Building Courses.
There are many ways to import data, however for our example, we will import our data into an ERD which will make it available to our screens later in this course.
Further reading on different ways to import data can be found on Importing Data.
Create an ERD
- From your application's home screen, click ERD.
- The ERD screen opens.
- Click Add New and enter:
- Name,
My Data
- Description, a description of what the ERD will be used for.
- Click Create.
- Name,
Upload Data
- On your PC, open the folder containing all of the resource files downloaded and extracted in Screen Building Courses
- Note, the files must be extracted from the folder before importing the data to PhixFlow.
- Drag the following files, one at a time, onto your ERD diagram:
- Companies
- Employees
- ISOCountryCodes
- Order-Lines
- Orders
- The tables are created in PhixFlow and will be available to our screens when we create them.
If you have data in PhixFlow already, you can add these tables to your ERD from the repository:
- To access your tables click the Table.
- Locate your table.
- Drag it from the repository onto the ERD.
- If you do not have a primary key set it is strongly recommended you do so, see the next section for details. Setting a Display Name is recommended but optional.
Set the Attributes
Now we will set up the following:
- Primary Keys for each table so we can uniquely identify each record.
- Display Names so we see the defined field instead of an ID.
- Relationships between tables so we can create relational views.
- See Entity Relationship Diagrams for more information on these concepts.
- Companies Table
- Right-click on CompanyID, and select
Make Primary Key
. - Right-click on CompanyName, and select
Make Display Name
.
- Right-click on CompanyID, and select
- Employee Table
- Right-click on EmployeeID, and select
Make Primary Key
. - Right-click on first_name, and select
Make Display Name
.
- Right-click on EmployeeID, and select
- ISO Country Codes Tables
- Right-click on CountryCode, and select
Make Primary Key
. - Right-click on CountryName, and select
Make Display Name
.
- Right-click on CountryCode, and select
- Orders Table
- Right-click on Order_ID, and select
Make Primary Key
.
- Right-click on Order_ID, and select
- Order Lines Table
- Right-click on OrderLineID, and select
Make Primary Key.
- Right-click on OrderLineID, and select
Set the Table Relationships
Relationships between tables allow us to associate the data logically using keys. For example, the company MyBusiness Ltd has these Employees. We use primary and foreign keys to create relationships.
- Companies to Employees
- On the Companies table, click and hold on the attribute CompanyID and drag it onto CompanyID on the Employee table. This will later allow us to access company information on a view of data showing employees i.e. who the employee works for. This is illustrated here.
- On the Companies table, click and hold on the attribute CompanyID and drag it onto CompanyID on the Employee table. This will later allow us to access company information on a view of data showing employees i.e. who the employee works for. This is illustrated here.
- Companies to ISOCountryCodes
- On the Companies table, click and hold on the attribute CountryCode and drag it onto CountryCode on the ISOCountryCode table. This will allow us to store a Country Code against the company but display the more ubiquitous Country Name in view.
- Companies to Orders
- On the Companies table drag CompanyID onto Customer_ID on the Orders table.
- Orders to OrderLines
- On the Orders table drag Order_ID onto OrderID on the OrderLines table.
Adding Bends
Adding bends to the relationship lines allows us to keep our diagrams neat and clear.
- Add bends to your relationships by clicking and holding the relationship line and dragging it to the required location:
Checkpoint
Your diagram should look like this:
Adding Data using an Analysis Model
If you have a large amount of data, the data is held in a different format or the data needs to be processed before it is ready to be displayed, for example, if it needs deduplicating or enriching, then you will need to import your data through an Analysis Model. Once your data is in an Analysis Model you can enrich and process it. For more information on this topic see: