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

Association supported #29

Open
draveness opened this issue Sep 13, 2016 · 3 comments
Open

Association supported #29

draveness opened this issue Sep 13, 2016 · 3 comments

Comments

@draveness
Copy link
Member

Supporting all association in SQLite needs too much work, especially when related to the association. The many-to-many relation is hard to implement in the project because it's so complicated and we need to deal with different edge cases.

In order to reduce the complexcity of this lib. We decided to remove the foreign key from the whole project and use binary to store these kinds of relation.

@draveness
Copy link
Member Author

draveness commented Sep 13, 2016

#9 #19

@draveness
Copy link
Member Author

draveness commented Sep 13, 2016

Two kinds of implementation:

Use comment.1

Each model should have an association property which at the second position in database:

privatedId, association, ...

The type of association is TEXT, and it contains all the association information of current value. ex:

"comment.1 person.2 shopping_item.1"

Each association value is separated by a space, type and privatedId are separated by a dot ..

Use single privatedId with some associations value

commentsAssociation = "1 2 3"
peopleAssociation = "1 2 4"

@draveness draveness assigned Desgard, mmoaay and silencewwt and unassigned Desgard Sep 13, 2016
@draveness
Copy link
Member Author

draveness commented Sep 13, 2016

After discussion, we decide to use association table instead of all foreign key. Separate models and associations. If there is association like this.

define :article do
  has_many :comments
end

define :comment do
  belongs_to :article
end

Models defined above will generate an association table called article_comment_association automatically.

column: privateId, articleId, commentId

draveness added a commit that referenced this issue Sep 14, 2016
preliminary add association support #29
@draveness draveness changed the title Remove foreign key from project Association supported Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
MetaModel 1.0
In Progress
Development

No branches or pull requests

5 participants