relationship

Using polymorph many-to-many self referencing relation with attributes on the relation in rails

Hi, I'd like to create a self referencing relation in rails. I have a Person model, and the person should have masters and pupils with same Person object. So far I tried: class Person <ActiveRecord::Base has_many :relationships, :dependent => :destroy has_many :masters, :through => :relationships, :conditions => "status='master'"...

Getting a list of related models in rails

Suppose I have an object Person, which has_many :foos and :bars. Given an instance, p (p = Person.new), how do I programmatically determine what relationships are available? i.e. p.some_method => ["foo", "bar"] ...

Implementation of an enforced one-to-many relationship in C#?

In my app, I'm working with Simfile and Notechart objects. A Simfile is essentially a Notechart container, with the following constraints: 1) Every Notechart must be contained in exactly one parent Simfile, at all times. 2) Given a Simfile object, I need to be able to obtain all of its contained Notecharts (should be easy). 3) Given a N...

CoreData Relationships Lazy Load?

When I have a CoreData entity named, say, 'Book', which has a one-to-one relationship with another entity ('Bookmark') would I need to insert both an instance of 'Book' and an instance of 'Bookmark' into a managed object context, and manually assign the relationship? If I perform the following code to instantiate an instance of 'Book'.....

Rails relationship modelling

I have a users table and a gifts table. Users can pick gifts for their friends. I am thinking of creating a table to store user id and gift id to track which user picked which gift for whom. How to model this relation? I think users and gifts have a HABTM relation. Is that right? ...

Core-Data: how to save an object twice in one relationship.

Hi there, say i have NSManagedObject A, that has a many-to-many relationship to NSManagedObject B. I have one saved instance of A and B. (not yet related) Now I want A to save the instance of B twice in its relationship, which is of course a set. Though, since its a set it stores only one reference of B. see: (not syntax checked) NS...

What type is on the other end of relation in sqlalchemy without creating objects?

How to obtain a name of the class that should be on the other end of the relation? It was declared when creating relationship. I guess that information should be somwhere in sqlalchemy.orm.util.class_mapper Let's say we have these three classes and a relations between them. Book * --- 1 Shelf and Book * --- * Author class Shelf(Base)...

Best way to store complex relations of huge amount of data php/mysql

I'm trying to develop a web based digital asset management application. I'm planning to do it in Codeigniter with mysql as db. This is for a popular regional newspaper. They will have 1000 of entries and TB's of data as daily tons of information will be entered. There will be different content types like Media, Personality, Event, Issu...

MySQL InnoDB doubled IDs

Hello all! http://img839.imageshack.us/img839/8241/stackoverflow.png I created a new databese. There are 2 tables class and teacher. There is a field class_leader in the table class related with teacher_id from teacher. [1] In PHPMyAdmin relationship looks like: [2] Table teacher contains some records. [3] When I add new records at ...

CoreData referencing

My application is CoreData based but they may be a common theory for all relational databases: I have a Output-Input to-many relationship in my model. There are potentially an unlimited number of links under this relationship for each entity. What is the best way to identify a specific input or output? The only way I have achieved thi...

Rails: Delete a Has-Many Relationship ONLY

Hey, I have a: has_and_belongs_to_many :friends, :join_table => "friends_peoples". To add a friend I do: @people.followers << @friend which create the relationship and a new person profile. Now I'd like to delete the relationship ONLY and not the person profile. I tried @people.friends.delete(guilty.id) but it deletes the person pro...

Kohana v3 ORM Select and Where clause based on different table.

Hi I need to do something like this: $hours->task->job->where('group_id' , '=' , $num)->find_all(); This would return job information. Is there any way to tell orm to return the information from the $hours table instead? ...

Drupal views relations question

Hi, In Drupal I have 3 content types( A, B, C ) see link. A and C contain a node reference to B. Now I have a view which queries fields from A from an argument. I want to also show fields from C trough the relationschip with B, so: A has a nodereference of ID:1, B has a Node ID:1, I want to show fields from C where nodereference of ID...

How to find its owner DataGrid and DataGridRow from DataGridCell in WPF?

In an event handler for a Command for a DataGrid, I get DataGridCell in ExecutedRoutedEventArgs. However, I couldn't figure out how to get its associated DataGrid and DataGridRow. Your help is much appreciated. ...

show relationships like Access

Is there a way to show table relationships as can be done in Access? Consider two tables: Services serviceid application id Application application id application name I have already set up the diagram. When opening the table service id I want to see the related application details like in Access. Is this possible? ...

A very interesting problem with SQL Server Relationships (SQL Server 2008R2, LINQ To SQL, Visual Studio 2010, C#)

I'm working on a web project. I'm using a Sql Server 20008 R2 database via LINQ To SQL, and today I faced a very strange problem with relationships. I've been using them for a while and never had any problems so far. Let's say I have a table Stores that has the following fields: ID, Name, LastUserID where LastUserID is a "reference" to ...

Active Record Query with Calculated Field

I am trying to use a query with a calculated field in a Yii Relationship definition but all I get is errors. Here is my query: $me = new CDbExpression('CONCAT_WS(\', \', last_name, first_name) AS the_name'); Here is my relation: 'author' => array(self::BELONGS_TO, 'Author', 'auth_id', 'select'=>$me), My problem seems to be that CDbExp...

Using PHP and Kohana 3, can one recursively find and output any model's relationships?

Let's say we have a User Model that has many Posts. The Posts Model has many Categories The Posts Model also has many Comments. How do we find dynamically, the relationships that the User Model has? The idea is to make an admin backend to a site, where I can have one function, that when passed a model, can retrieve all data related t...

How to where conditions with Zend_DB Table Relations?

I have a two table in relation with has_many assocation on theirselves. How can i call has_many table with where condition? When i call like "$news -> findNewsComment();" i get Comments. but i want specific comments, like just approved comments. is it possible something like $news -> findNewsComment(array('state_id = ?' => '10')); ...

Rails authentication gift list for each user?

Hi Everyone, I am trying to get to grips with the basics of authentication in Rails. To start with I have used the nifty_authentication generator by Ryan Bates. It's helping me learn the basic options for user logins etc. I have a simple application the has a person and gift table in the database. The idea is, each user creates a list...