As part of my Common Data Service series I introduced entities in the first part of this post. Time to get on with creating an Entity. In this post I will create an entity for Cars. The New Entity form will ask me for the singular and the plural name for the entity.
Fields
Table of Contents
I’m also supplying the primary field for the cars. I’m choosing the use the number plate as a unique primary field.
Once the entity has been created I can now add more fields to my entity.
I could now choose to add a field called brand where you can register the brand of the car. This could be a simple text field. But I could also choose to use an option set. that then gives the user the option to select the brand of the car from a pre-populated drop down list.
Ok, there are choices to be made. Like mentioned before you want to make sure that you make the right choices. With some many data types available in can be difficult to get it right.
But that is not all.
You can also create calculated fields or Rollup fields. Rollup fields can be used to collect information across relation ships on entities. So for example if there was a relation ship between people and cars called drivers. Then you could calculate the total age of all drivers.
Relationships
Once you have added all your fields to an entity you might find that you want to create relation ships between entities.
With relation ships you can specify how one identity relates to another. There are 3 different types of relationships possible.
- Many to one
- One to many
- Many to many
When we look at the drivers relation ship mentioned before you will have to make a data design choice here.
- Can you have more than one driver for one car?
- Can you drive in more than one car?
The difficulty here can be that when you design your data you are sure that a relation ships of one type and then later on you decide that you may need a different type of relationship. In my case I’m going for the One-to-Many relationship. I will have one car with multiple drivers.
Business Rules, Views, Forms, Dashboard and charts
Related to your entity you can specify business rules, views, forms, dashboards and charts. This becomes important as you look at Model driven apps. So far all I’ve looked at in these posts is related to canvas apps and flows. I will look at business rules, views and forms in my post about Model driven apps and flows.
Keys
As always with relational databases keys are key in your database design. Within the Key configuration section of my entities I can specify which fields make up the key.
More information on CDS
Common Data Service – a complete overview