[odb-users] many-to-many with two FKs

Marcel Nehring mne at qosmotec.com
Thu Sep 17 05:38:12 EDT 2015


Hi all,

when modeling a many-to-many relationship in ODB the corresponding mapping table will have only one foreign key. Is there any way to make it two? Is there a reason not to make it two that I don't see?

Instead of

CREATE TABLE project (
name VARCHAR (255) NOT NULL PRIMARY KEY);

CREATE TABLE employee (
id BIGINT UNSIGNED NOT NULL PRIMARY KEY);

CREATE TABLE employee_projects (
object_id BIGINT UNSIGNED NOT NULL,
value VARCHAR (255) NOT NULL REFERENCES project (name));

I would like

CREATE TABLE project (
name VARCHAR (255) NOT NULL PRIMARY KEY);

CREATE TABLE employee (
id BIGINT UNSIGNED NOT NULL PRIMARY KEY);

CREATE TABLE employee_projects (
object_id BIGINT UNSIGNED NOT NULL REFERENCES employee (id),
value VARCHAR (255) NOT NULL REFERENCES project (name));

Regards,
      Marcel


More information about the odb-users mailing list