Comment on page
The Data model is the foundation of a solution. It contains a definition of how your data is structured and how it is connected. The data model is shared across all apps and services in a solution. A data model is made up of object classes and enumerated types (enums).
An object class is a structured definition of a single business object. Often, this data is reflected in the real world somehow. If you have worked with a spreadsheet in Microsoft Excel this will be familiar. For example you might have a sheet for registering employees called
Employees. In the sheet there are columns with the headers
Email Address. For each cell you can format what type of data it should contain, for example text (string), a date, or a number (integer).
To represent this structure in the data model you would create an object class
Employee. You would then add object class properties for each column (
Firstname, etc). Within an app you can create and modify
Employeeobjects based on this definition and store them in the database. Objects represent the rows in your spreadsheet.
An enum is a set of key-value pairs used to define constant values in a solution. Continuing the example above, you might create an enum called
Departmentsto store the names of the different departments in the company. You can add this enum as an object class property and restrict the possible departments an
Employeeobject can have to those you have defined.
The Data model in Appfarm Create
In the table view you can expand and collapse the object classes to view and add properties.
In the diagram view, you can drag and drop the object classes around the canvas. You can expand and collapse each object class to show or hide the properties. When expanded, tags are represented by a colored line at the bottom. The lines between the object classes indicate that they are connected with reference properties.
To add a new tag to your data model:
- Click the tags icon at the top of the data model designer.
- Click Create new tag.
- Enter a Tag name and select a color to represent the tag.
- Click Add tag.
In the top section of the Global Data Model, you may filter the Object Classes - both from the diagram view and list view. You may filter by Tags, or choose to se the Data Model just for a single App or Service by selecting an App or Service in the App Scoped Data Model or Service Scoped Data Model, as seen below.
See the Data Model for a single App
Note that downloading Apps from the Farmers Market, some of these Apps comes with a Scoped Data Model. A Scoped Data Model contains Object Classes that only exists in that App. Once the App is deleted, so are the Scoped Object Classes. A Scoped Object Class may be turned into a Global Object Class in order for other Apps to use these Object Classes as well.
The Appfarm platform has built-in support for querying your data through GraphQL. GraphQL can be used as a developer tool to view and modify data in your solution, as well as a method for exposing your data model to external parties for integration.
To access the GraphiQL IDE for your environments:
- Click Explore GraphQL in the toolbar.
- Click the relevant button for the environment you wish to access and the GraphiQL will open in a new tab.