A way to model a one-to-one relationship in a circuit?

For example, I have a cars table, each has a model and a make . A car can have only one, and there is a table of models and makes , while their identifiers are automatically generated. Can I reference them in my cars table? What does JSON look like?

I tried to create a new field in the cars table and specify id in the Via textbox, but it just creates a new column in the corresponding id1 table. Is there a proper way?

Here is my sample JSON schema:

  { "name": "cars", "fields": { "model": { "object": "models" }, "make": { "object": "makes" } } }, { "name": "models", "fields": { "title": { "type": "string" }, "make": { "object": "makes" }, "id": { "collection": "cars", "via": "model" } } }, { "name": "makes", "fields": { "models": { "collection": "models", "via": "make" }, "title": { "type": "string" }, "id": { "collection": "cars", "via": "make" } } } 
+5
source share
1 answer

In Back &, by definition, there is no one-to-one relationship, but we are looking for you one-to-many, and you almost got it, see the model below. In the model below, a car can have the same model and one brand (of course, models and models can have many cars - this is a lot):

 { "name": "cars", "fields": { "model": { "object": "models" }, "make": { "object": "makes" } } }, { "name": "models", "fields": { "cars": { "collection": "cars", "via": "model" }, "title": { "type": "string" }, "make": { "object": "makes" } } }, { "name": "makes", "fields": { "cars": { "collection": "cars", "via": "make" }, "models": { "collection": "models", "via": "make" }, "title": { "type": "string" } } } 
+3
source

Source: https://habr.com/ru/post/1247884/


All Articles