1 - Build Database Tables
Last updated 27/03/2023
To take your knowledge of Five further, you will need to create three more tables to 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.![Portfolio Base Model Stage Two](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/navigate/portfolio-stage-two-model.png)
Figure 1 - Portfolio stage two model
Navigate to Tables
1. Select the Portfolio record in the application list.2. Click the Manage button in the form app bar.
![Manage Button](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/navigate/manage-button.png)
Figure 2 - Manage button
3. Select Data in the menu.
4. Select Tables in the sub-menu.
![Tables Menu Item](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/navigate/tables-menu-item.png)
Figure 3 - Tables menu item
Add the Buy Table
1. Click the New Table Wizard button.2. Type Buy in the Name field.
![Add the Buy Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-buy-table.png)
Figure 4 - Add the Buy table
3. Click the Add Fields button.
4. Type TransactionDate in the Name field.
![Add the TransactionDate Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-transactiondate-field.png)
Figure 5 - Add the TransactionDate field
5. Click the Add Fields button.
6. Type Quantity in the Name field.
7. Click the Req. checkbox.
![Add the Quantity Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-quantity-field.png)
Figure 6 - Add the Quantity field
8. Click the Add Fields button.
9. Type Price in the Name field.
10. Click the lookup icon in the Data Type field and select Float.
![Add the Price Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-price-field.png)
Figure 7 - Add the Price field
11. Click the Add Fields button.
12. Type Fees in the Name field.
13. Click the lookup icon in the Data Type field and select Float.
![Add the Fees Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-fees-field.png)
Figure 8 - Add the Fees field
14. Click the Add Fields button.
15. Type Total in the Name field.
16. Click the lookup icon in the Data Type field and select Float.
17. Click the Req. checkbox.
![Add the Total Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-total-field.png)
Figure 9 - Add the Total field
18. Click the Next button.
![Next Button](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/next-button.png)
Figure 10 - Next button
19. Click the Add Relationships button.
20. Click the lookup icon in the Table field and select Portfolio.
21. Click the Required checkbox.
![Add the Portfolio Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-portfolio-relationship.png)
Figure 11 - Add the Portfolio relationship
22. Click the Add Relationships button.
23. Click the lookup icon in the Table field and select Stock.
24. Click the Required checkbox.
![Add the Stock Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/add-stock-relationship.png)
Figure 12 - Add the Stock relationship
25. Click the Save button in the Table Wizard app bar.
![Save the Buy Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/buy-table/save-buy-table.png)
Figure 13 - Save the Buy table
Add the Sell Table
1. Click the New Table Wizard button.2. Type Sell in the Name field.
![Add the Sell Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-sell-table.png)
Figure 14 - Add the Sell table
3. Click the Add Fields button.
4. Type TransactionDate in the Name field.
![Add the TransactionDate Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-transactiondate-field.png)
Figure 15 - Add the TransactionDate field
5. Click the Add Fields button.
6. Type Quantity in the Name field.
7. Click the Req. checkbox.
![Add the Quantity Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-quantity-field.png)
Figure 16 - Add the Quantity field
8. Click the Add Fields button.
9. Type Price in the Name field.
10. Click the lookup icon in the Data Type field and select Float.
![Add the Price Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-price-field.png)
Figure 17 - Add the Price field
11. Click the Add Fields button.
12. Type Fees in the Name field.
13. Click the lookup icon in the Data Type field and select Float.
![Add the Fees Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-fees-field.png)
Figure 18 - Add the Fees field
14. Click the Add Fields button.
15. Type Total in the Name field.
16. Click the lookup icon in the Data Type field and select Float.
17. Click the Req. checkbox.
![Add the Total Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-total-field.png)
Figure 19 - Add the Total field
18. Click the Next button.
![Next Button](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/next-button.png)
Figure 20 - Next button
19. Click the Add Relationships button.
20. Click the lookup icon in the Table field and select Portfolio.
21. Click the Required checkbox.
![Add the Portfolio Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-portfolio-relationship.png)
Figure 21 - Add the Portfolio relationship
22. Click the Add Relationships button.
23. Click the lookup icon in the Table field and select Stock.
24. Click the Required checkbox.
![Add the Stock Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/add-stock-relationship.png)
Figure 22 - Add the Stock relationship
25. Click the Save button in the Table Wizard app bar.
![Save the Sell Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/sell-table/save-sell-table.png)
Figure 23 - Save the Sell table
Add the Allocation Table
1. Click the New Table Wizard button.2. Type Allocation in the Name field.
![Add the Allocation Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/add-allocation-table.png)
Figure 24 - Add the Allocation table
3. Click the Add Fields button.
4. Type Quantity in the Name field.
![Add the Quantity Field](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/add-quantity-field.png)
Figure 25 - Add the Quantity field
5. Click the Next button.
![Next Button](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/next-button.png)
Figure 26 - Next button
6. Click the Add Relationships button.
7. Click the lookup icon in the Table field and select Sell.
8. Click the Required checkbox.
![Add the Sell Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/add-sell-relationship.png)
Figure 27 - Add the Sell relationship
9. Click the Add Relationships button.
10. Click the lookup icon in the Table field and select Buy.
11. Click the Required checkbox.
![Add the Buy Relationship](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/add-buy-relationship.png)
Figure 28 - Add the Buy relationship
12. Click the Save button in the Table Wizard app bar.
![Save the Allocation Table](/2.1/img/learning-resources/portfolio/intermediate/build-database-tables/allocation-table/save-allocation-table.png)
Figure 29 - Save the Allocation table