Most entities are not isolated and they are related to another entity in a one-to-one, one-to-many or many-to-many relationship. CRUDigniter helps you manage one-to-many relationships in your code. Let us illustrate this with the help of an example:
Consider an invoice management application where there are 2 entities : invoices and customers. The relationship betweem these two entities is one-to-many viz. one customer CAN have many invoices but one invoice CANNOT have many customers. It can be represented by an EER diagram as follows :
For the above database schema, If we were to build a UI Form, it would look like the one below.
In this form, the HTML code for select will be :
The number in the value="5" comes from the column `id` in the database (primary key) and the value inside the dropdown comes from the `first_name` column.
Thus, we can conclude that in a one-to-many association, the data displayed in the form consists of two parts :
- The value inside the value="" attribute (primary key of the associated table)
- The value inside the dropdown (column in the associated table)