I am modeling how website pages can link to each other with Path &
Edge models.
DB.create_table paths {
Integer id
String path
primary_key [:id], :name => :pk_paths_id
}
DB.create_table :edges {
Integer id
Integer from_path_id
Integer to_path_id
primary_key [:id], :name => :pk_edges_id
foreign_key [:from_path_id], :paths, :name => :fk__paths__id__1
foreign_key [:to_path_id], :paths, :name => :fk__paths__id__2
}
Short example of from_path_id and to_path_id values in edges table.
1, 1
1, 2
1, 3
2, 1
2, 3
How would I set the association for Path model?
class Path < Sequel::Model
many_to_many :paths, :join_table => :edges # is this correct?
...
end
class Edge < Sequel::Model
...
end
I understand how one_to_many, many_to_one, and many_to_many works when
it's different tables, such has books, books_authors, authors. I've
only found ActiveRecord examples/solutions for tables with
many_to_many relationship to itself.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.