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

Support one-to-many relationships #10

Closed
rexxars opened this issue Aug 12, 2015 · 5 comments
Closed

Support one-to-many relationships #10

rexxars opened this issue Aug 12, 2015 · 5 comments

Comments

@rexxars
Copy link
Owner

rexxars commented Aug 12, 2015

We currently support one-to-one, but we should definitely also support one-to-many.

@kbrabrand
Copy link
Contributor

I have been thinking about this. I'll see if I can make something within the next week or so.

@rexxars
Copy link
Owner Author

rexxars commented Aug 18, 2015

👍 This would be a great addition

@rexxars
Copy link
Owner Author

rexxars commented Aug 26, 2015

@kbrabrand Did you get anywhere with this?

I think this should work:

SELECT COUNT(`potential_column`) AS `hasSameValues`
FROM `someTable`
GROUP BY `potential_column`
HAVING `hasSameValues` > 1
LIMIT 1;

Currently we find all columns which matches the name of some other table (eg, forum_id from a threads table, assume it's a reference to the primary key within forums table).

If we in this step run the query to find out if there are duplicate values, then we should be able to assume that going the other way (forum => threads in this case) is going to be a valid one-to-many connection.

I'll start implementing this, unless you already have something in progress?

@kbrabrand
Copy link
Contributor

I got as far as writing that query, but no more than that.. 😔 It derailed when I took down a server doing a dump

@rexxars
Copy link
Owner Author

rexxars commented Aug 26, 2015

Haha, alright. I'll take a look :-)

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

No branches or pull requests

2 participants