similar to: how do I model self-referential entities?

Displaying 20 results from an estimated 3000 matches similar to: "how do I model self-referential entities?"

2006 Aug 02
2
Self-Referential has_many :through
Hello all. I am trying to create a self-referential has_many :through. I used the following site as a guide http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through but it still doesn''t appear to be working. I have two models. Person and Relationship. A person has many contacts (Which is another person) through relationships class Person < ActiveRecord::Base
2006 May 28
7
Self-referential has_many :through relationship
Hi, I have a self-referential has_many :through relationship setup to track relationships between users. Basically relationships are modeled as a join table with an extra column ''relation''. create table relationships ( user_id integer unsigned not null, friend_id integer unsigned not null, relation char(1) not null, ) --- relations --- f = friend r = request to
2006 Aug 15
2
How to access attribute in a self-referential many-to-many relationship
Hello List, I created a self-referential many-to-many relationship (as described in the book Rails recipe #18), where I have a model that has many-to-many relationships with itself. In this case, it''s person who can become friends. The join table looks like this: mysql> select * from friends_people; +-----------+-----------+-----------+ | person_id | friend_id | confirmed |
2006 May 20
7
Polymorphic, many-to-many, self-referential data model
No matter what I try I''ve been unable to work how to get this to work with the cool ActiveRecord helpers. I''m not sure if it''s possible, Josh Susser''s blog suggests it is, but damned if I can work it out... I have: Container which can contain one or more Element. An Element is a polymorph of either a Container or a Chunk. An Element can exist in one or more
2006 May 23
7
self-referencing has_many
Having a devil of a time finding records in a self-referencing has_many table relationship. Everything is working find looking at the has_many and the belongs_to relationship. But, when I try to find all "orphans", records that are neither a parent nor a child, I can not find a query that work in ActiveRecord. This query works in MySQL: SELECT * FROM templates LEFT JOIN templates
2006 May 19
7
How can I set up relations for these models?
Hello! I have a legacy DB and want to use ActiveRecord for it. However, I can''t set up a relation correctly. Here''s table spec: [products] id name price [subproducts] product_id subproduct_id Some example data: [products] 1, "Computer", 500.00 2, "Monitor", 200.00 3, "Printer", 100.00 4, "System", 700.00 5, "System2",
2006 May 16
4
Problems with multiple ''id'' columns in a join_table
I have a problem declaring a relationship through a join_table ; the SQL generated by ActiveRecord is correct, but there are two columns called ''id'', and the final object gets the ''wrong'' column ... Here''s a more detailed description of the data, code, and problem :- There''s a People table, with id, name, and a few things. Also a
2006 Apr 20
4
Many to Many Category structure with itself
Basically, I''m trying to have a table called "categories" have a many to many relationship with itself. But I also want each catagory to be able to be "copied" into another category so it is essentially a child category to more than one parent. To me the obvious way of doing this is by creating another table called category_maps (and a model called CategoryMap).
2006 Nov 02
4
Still Having Problems With :through When Going To Same Table... Help... please :-(
I am having a problem with doing a :through that goes back to the same table. The following are my two classes: >>>>> class User < ActiveRecord::Base has_many :spanks has_many :spanked, :through => :spanks, :source => :spanked_user has_many :was_spanked_by, :through => :spanks, :source => :user end class Spank < ActiveRecord::Base belongs_to :spanker,
2006 Apr 05
4
Self-referential join creation/deletion and :through
Greetings. First, this example is just my way of exploring :through. It probably doesn''t need has_many :through, and could just use a standard HABTM association. Here''s the models: class CourseRequisite < ActiveRecord::Base belongs_to :requisite, :class_name => ''Course'', :foreign_key => ''requisite_id'' belongs_to :course,
2006 Mar 29
4
:through alternate
I''d like to use :through to create a web of associations like: class Thing < ActiveRecord::Base has_many :child_things, :through => :thing_thing has_many :parent_things, :through => :thing_thing, :some_other_option? end class ThingThing < ActiveRecord::Base belongs_to :thing belongs_to :child_thing, :class_name => ''Thing'', :foreign_key =>
2006 Mar 31
6
Adding objects to a :through association
So I''m one of those nasty people building a self-referential habtm-like Association using the funky new :through stuff. This is about users having friends, so here''s my user.rb: class User < ActiveRecord::Base has_many :friendships, :foreign_key => ''user_id'' has_many :friends, :through => :friendships, :source => :friend end And here''s
2012 Oct 22
4
[LLVMdev] Self-referential instruction from jump threading
Hello, After investigating PR14133, I've discovered that jump threading can output self-referential instructions: %inc.us = add nsw i32 %inc.us, 1 At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this instruction causes BBVectorize to hang. Should
2012 Oct 22
0
[LLVMdev] Self-referential instruction from jump threading
Hi Hal, > After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1 such instructions are valid in unreachable basic blocks. > At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when
2012 Oct 22
0
[LLVMdev] Self-referential instruction from jump threading
Hal Finkel wrote: > Hello, > > After investigating PR14133, I've discovered that jump threading can output self-referential instructions: > %inc.us = add nsw i32 %inc.us, 1 > > At least in the test case for that bug report, the relevant code is later deleted (perhaps it is unreachable), and so this does not cause a problem. Unfortunately, when vectorization is enabled, this
2006 May 28
3
Association of table to itself
I''m curious what would be the best way to represent people and whether the person has someone marked as their friend. Here are my thoughts so far: People table - id - name Relationships table - person_id - friend_id Now my problem is I don''t know how to set up these associations (if this is even correct). Friend_id would be an id to someone else from the people table.
2006 May 30
1
Having two columns in a model point to another table
Hey, I''m kind of new to Rails, and would appreciate it if someone could point me in the right direction on this. I have a "users" table in my application, and I wanted to set up a "debts" table, to store debts between users. My current table structure for "debts" is CREATE TABLE debts ( id int not null auto_increment, owed_user_id int not null, # User
2012 Jul 06
2
[LLVMdev] Self-referential function pointer
Hey guys, I could use some advice on a special case of a function pointer as a formal argument. I would like the function pointer type to contain the actual signature of the function, i.e. not a pointer to var args function. This becomes an issue when I have a function which can take a pointer to itself as an argument... our terminology for this is "a recursive procedure". That is, of
2006 Jun 23
2
polymorphic challenge
Hello All, I have a little challenge and I am not sure if this is even possible I am working on a dating/event site and few functionalities are similar that I want to centralize them. We have users which can have - favorite users - interest list - blocked users All these relations are like; User <-> Relation <-> User I was thinking I could have a class called Relation (with a
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table has another "non-joiny" attribute. I went from this: has_many_and_belongs_to :jobs, :join_table => ''tablename'', :foreign_key => ''x'', :association_foreign_key => ''y'' to this: has_many :jobs, :through =>