One-to-One Relations

A one-to-one relation means that one record in a type is associated with one record in another type.

 type Customer struct {
   id int unique, 
   relation addr Address optional parent one  
 } end
 type Address struct {
   id int unique, 
   relation cust Customer one 
 } end

Here, since Customer.addr is optional, then Customer can have zero or one addresses, whereas and each Address has one customer.

Delia will put the foreign key in one of the tables. You can control which table gets the foreign key using the parent modifer. One-to-one relations have a parent side and a child side. The foreign key is put into the child side of the relation. In our example, this is Address.

Note. When one side of a relation is optional and the other is mandatory, Delia will infer parent and child, even if the parent modifier is not present. The mandatory side will be the parent.

 type Customer struct {id int unique, relation addr Address optional one  } end //parent
 type Address struct {id int unique, relation cust Customer one } end //child

One-to-one relations must have at least one optional side.

Note. One-side relations are supported (see …)