Two one-to-many relationships on the same two entities
举例:一个人可以是许多汽车的拥有者,他也可以成为许多汽车的司机
Person (1) <---owns-----> (*) Car
Person (1) <---drives---> (*) Car
================= Person =================
Fields
name (String)
age (Integer)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Car
? What is the name of the relationship? ownedCar
? What is the type of the relationship? one-to-many
? What is the name of this relationship in the other entity? owner
================= Person =================
Fields
name (String)
age (Integer)
Relationships
ownedCar (Car) one-to-many
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Car
? What is the name of the relationship? drivedCar
? What is the type of the relationship? one-to-many
? What is the name of this relationship in the other entity? driver
================= Car =================
Fields
brand (String)
license (String)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Person
? What is the name of the relationship? owner
? What is the type of the relationship? many-to-one
? When you display this relationship with Angular, which field from ‘Owner’ do you want to use? This field will be displayed as a String, so it cannot be a Blob name
? Do you want to add any validation rules to this relationship? No
================= Car =================
Fields
brand (String)
license (String)
Relationships
owner (Owner) many-to-one
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Person
? What is the name of the relationship? driver
? What is the type of the relationship? many-to-one
? When you display this relationship with Angular, which field from ‘Owner’ do you want to use? This field will be displayed as a String, so it cannot be a Blob name
? Do you want to add any validation rules to this relationship? No
一辆汽车现在可以有一个司机和一个车主,都是个人实体。用户界面上,您将在汽车中下拉菜单以选择用于所有者字段和驱动程序字段的人员。
A many-to-many relationship
举例:司机可以驾驶很多车,但一辆车也可以有很多司机。
Driver (*) <-----> (*) Car
================= Driver =================
Fields
name (String)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Car
? What is the name of the relationship? car
? What is the type of the relationship? many-to-many
? Is this entity the owner of the relationship? No
? What is the name of this relationship in the other entity? driver
================= Car =================
Fields
brand (String)
license (String)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Driver
? What is the name of the relationship? driver
? What is the type of the relationship? many-to-many
? Is this entity the owner of the relationship? Yes
? What is the name of this relationship in the other entity? car
? When you display this relationship with Angular, which field from ‘Driver’ do you want to use? This field will be displayed as a String, so it cannot be a Blob name
? Do you want to add any validation rules to this relationship? No
现在在这两个实体之间有了多对多的关系!将在Car中选择多个下拉菜单来选择多个Driver,因为Car是所有者的一方。