On 10/14/17 5:35 AM, Simon Slavin wrote:

On 14 Oct 2017, at 10:30am, Csányi Pál <csanyi...@gmail.com> wrote:

With which constraints can one create a foreign key to
first: get one to one relationship, and
second: one to many relationship?
Foreign keys always implement a one-to-many relationship.

You could enforce a one-to-one relationship by using one foreign key in each 
direction.  But there could be problems when getting the data in in the first 
place — which one do you put in first ?

<https://sqlite.org/foreignkeys.html>

If you have problems with the above page, please post again.

Simon.
One way to make them build one to at-most-one relationships is too add a unique index on the foreign key, then it can only occur once.

A True one-one relationship by the normailization rules says that they should all be in the same record.

--
Richard Damon

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to