2 - Build Database Tables
Last updated 5/09/2024
When an application record is saved in Five, a MySQL database is created and Five automatically establishes the connection with the external database management system (DBMS).
This documentation will explain how to create and add tables to the MySQL database for the Portfolio application via Five's Table Wizard. In total, five tables will be added. The Portfolio database model below shows the relationships between the tables.
The Sector and StockExchange tables have a one-to-many relationship with the Stock table and the Stock table has a one-to-many relationship with the StockPrice table. At this stage no relationship has been established with the Portfolio table.
Navigate to the Table Wizard
1. Click the Manage button in the form app bar.2. Click Data in the menu.
3. Click Table Wizard in the sub-menu.
Add the Portfolio Table
1. Type Portfolio in the Name field.2. Click the Add Fields button.
3. Type Name in the Name field.
4. Click the Save button in the Table Wizard app bar.
5. Click the Save button in the Table Upgrade window.
Once you have saved a table via our Table Wizard, you will find the table record in the Tables view. To navigate to the Tables view, click Data in the menu followed by clicking Tables in the sub-menu.
Add the StockExchange Table
1. Click Data in the menu.
2. Click Table Wizard in the sub-menu.
3. Type StockExchange in the Name field.
4. Click the Add Fields button.
5. Type StockExchangeCode in the Name field.
6. Edit the Size field and type 20 in the Size field.
7. Click the Add Fields button.
8. Type Name in the Name field.
9. Click the Req. checkbox.
10. Click the Save button in the Table Wizard app bar.
11. Click the Save button in the Table Upgrade window.
Add the Sector Table
1. Type Sector in the Name field.2. Click the Add Fields button.
3. Type Name in the Name field.
4. Click the Save button in the Table Wizard app bar.
5. Click the Save button in the Table Upgrade window.
Add the Stock Table
1. Type Stock in the Name field.2. Click the Add Fields button.
3. Type StockCode in the Name field.
4. Edit the Size field and type 20 in the Size field.
5. Click the Add Fields button.
6. Type Name in the Name field.
7. Click the Req. checkbox.
8. Click the Next button.
9. Click the Add Relationships button.
10. Click the lookup icon in the Table field and select StockExchange.
11. Click the Required checkbox.
12. Click the Add Relationships button.
13. Click the lookup icon in the Table field and select Sector.
14. Click the Required checkbox.
15. Click the Save button in the Table Wizard app bar.
16. Click the Save button in the Table Upgrade window.
Add the StockPrice Table
1. Type StockPrice in the Name field.2. Click the Add Fields button.
3. Type PriceDate in the Name field.
4. Click the Add Fields button.
5. Type OpenPrice in the Name field.
6. Click the lookup icon in the Data Type field and select Float.
7. Click the Add Fields button.
8. Type HighPrice in the Name field.
9. Click the lookup icon in the Data Type field and select Float.
10. Click the Add Fields button.
11. Type LowPrice in the Name field.
12. Click the lookup icon in the Data Type field and select Float.
13. Click the Add Fields button.
14. Type ClosePrice in the Name field.
15. Click the lookup icon in the Data Type field and select Float.
16. Click the Add Fields button.
17. Type Volume in the Name field.
18. Click the lookup icon in the Data Type field and select Integer.
19. Click the Next button.
20. Click the Add Relationships button.
21. Click the lookup icon in the Table field and select Stock.
22. Click the Required checkbox.
23. Click the Save button in the Table Wizard app bar.
24. Click the Save button in the Table Upgrade window.