1 - Build Database Tables
Last updated 23/05/2025
To take your knowledge of Five further, you will need to create three more tables for the Portfolio application. To reflect these changes, the Portfolio database model has been updated. The Buy, Sell, and Allocation tables are now required so a user can make transactions and allocate stock for a sale.
The Stock table has a one-to-many relationship with both the Buy and Sell tables. The Portfolio table has a one-to-many relationship with both the Buy and Sell tables. The Buy and Sell tables both have a one-to-many relationship with the Allocation table.

Navigate to the Table Wizard
The new tables will be added via Five's Table Wizard.
1. Select Portfolio in the list.2. 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 Buy Table
1. Type Buy in the Name field.
2. Click the Add Fields button.
3. Type TransactionDate in the Name field.

4. Click the Add Fields button.
5. Type Quantity in the Name field.
6. Click the Req. checkbox.

7. Click the Add Fields button.
8. Type Price 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 Fees 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 Total in the Name field.
15. Click the lookup icon in the Data Type field and select Float.
16. Click the Req. checkbox.

17. Click the Next button.

18. Click the Add Relationships button.
19. Click the lookup icon in the Table field and select Portfolio.
20. Click the Required checkbox.

21. Click the Add Relationships button.
22. Click the lookup icon in the Table field and select Stock.
23. Click the Required checkbox.

24. Click the Save button in the Table Wizard app bar.

25. Click the Save button in the Table Upgrade window.

Navigate to the Tables View
The Sell table, which we will add next, has the same fields and table relationships as the Buy table. This is a good time to introduce Five's copy feature to duplicate the Buy table record. To do this we need to go to the Tables view.
1. Click Data in the menu.2. Click Tables in the sub-menu.

Add the Sell Table
When using the copy feature, Five exactly copies the record, so we will need to edit the data Sourse ID and the table name, and the primary field and index to reflect the Sell table.
1. Select the Buy record in the list.2. Click the Copy button in the form app bar.

3. Click the Cancel button in the Data Source ID field and type Sell.
4. Click the Cancel button in the Table Name field and type Sell.

5. Click the Fields tab.

6. Select the BuyKey record.

7. Either click the Edit button in the form app bar, or click directly in the Field ID field.

8. Click the Cancel button in the Field ID field and type SellKey.
9. Click the Save button in the form app bar.

10. Click the Indices tab.

11. Select the BuyKey record.

12. Either click the Edit button in the form app bar, or click directly in the Index ID field.

13. Click the Cancel button in the Index ID field and type SellKey.
14. Click the Save button in the form app bar.

15. Click the Save button in the form app bar above the list.

16. Click the Save button in the Table Upgrade window.

Navigate to the Table Wizard
One last table needs to be added into the Portfolio application, we'll go back to the Table Wizard to do this.
1. Click Data in the menu.2. Click Table Wizard in the sub-menu.

Add the Allocation Table
1. Type Allocation in the Name field.
2. Click the Add Fields button.
3. Type Quantity in the Name field.

4. Click the Next button.

5. Click the Add Relationships button.
6. Click the lookup icon in the Table field and select Sell.
7. Click the Required checkbox.

8. Click the Add Relationships button.
9. Click the lookup icon in the Table field and select Buy.
10. Click the Required checkbox.

11. Click the Save button in the Table Wizard app bar.

12. Click the Save button in the Table Upgrade window.
