Edit Data Models
ROQ provides a database model or schema editor sometime we call it Data Model Editor. It is designed so you can easily customize the generated application data model to meet your business needs.
You can access the Data Model Editor feature in ROQ Console with a few ways:
You can access the data model editor from the onboarding page. Go to Home → Get Started page and find the Step 3: Fine-tune your database model section and click the Edit Data Model button.
You can access the data model editor in the generated application too. There is an
Edit data model button in the top of the generated application.
Using the Data Model Editor, you can add models, add fields, create and edit relationships.
Depending on the generated application, the screenshot below shows entities for the Library Management application.
Let's take an example, to add a new model or new table into the database for a Library Management application. Suppose we want to add ISBN data model into the database, these are the typical neccessary steps:
To add a new model (essentially the same with add a new table), click the + Add new table button and then ROQ will provides a new table with the default fields and values.
For our ISBN data model we can name the table
isbn* and then we can add
number field to the model.
Generally a book will have one and only one ISBN. From this information we can specify the relationship between book and isbn is One to One.
You can add or edit the relationship with clicking the Edit relationships button and then select the options:
- Select Related Model:
- Model Relationships:
One to One
- Foreign Key Name:
Save every changes with clicking the Save button.
To apply new models to the application, we need to regenerate the application.
You can do this by clicking the Generate Application button and then ROQ will regenerate the application with the new models applied.
This regeneration process will create a new application version, yes now you have two application versions, and you can select the application version from the Environment → Projects menu.