Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many-to-many using the same table 2 times #83

Open
mrsoto opened this issue Oct 28, 2015 · 2 comments
Open

Many-to-many using the same table 2 times #83

mrsoto opened this issue Oct 28, 2015 · 2 comments

Comments

@mrsoto
Copy link

mrsoto commented Oct 28, 2015

Hello,
How columns should be names to allow a many-to-many relationship when the same table is referenced, for example

table customer(id)
table customer_customer(id, customer_id, other_customer_id, other_data)

how the other_customer_id should be named to be respect compliant?

@mrsoto mrsoto changed the title Many-to-many between using the same table 2 times Many-to-many using the same table 2 times Oct 28, 2015
@nawarian
Copy link

nawarian commented Dec 7, 2015

I can't find right now a way to do that without setting a custom Style or defining a third table to perform that...

@alganet
Copy link
Member

alganet commented Dec 8, 2015

I have been using views for that:

CREATE TABLE customer(id ...);
CREATE VIEW friend AS SELECT * FROM customer;
CREATE TABLE customer_friend(id .., customer_id ..., friend_id ..., friendship_status ...);

The view friend mimics the customer table and allows relational to target the same data using different collection names. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants