many-to-many

MySQL query, intersection on many-to-many relationship

Does someone have a good idea/solution how to achieve this? Situation is: I have the tables 'releases' and 'ntags', related via 'releases_ntags' (containing 'release_id' and 'ntag_id') And I would like to fetch results for releases via the ntag's 'slug'. I manage to have this semi-working: sql SELECT r.id, r.name FROM releases r LE...

Changing part of a composite-id

I have a class, BillMedicine, which is many-to-many table for Bill and Medicine. The BillMedicine mapping file is: <class name="BillMedicine" table="Bill_Medicine"> <composite-id> <key-many-to-one name="Bill" class="Bill" column="BillID" /> <key-many-to-one name="Medicine" class="Medicine" column="MedicineID" /> ...

Remove from one side of the many to many in Nhibernate

Hi there, I have these 2 objects in NHibernate forming a many to many relationship: User: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Providers" namespace="Providers.Objects"> <class name="User" table="Users"> <id name="UserId" type="int"> <ge...

GUI Component or class-library to visualize many-to-many relationship?

Are there any components or class libraries (.NET, Silverlight, Javascript) which are able to visualize / navigate data in a many-to-many relationship? Similarly as a Treeview is able to visualize / navigate parent-child related data. I'm looking for a way to view some object and N levels of related objects. ...

Django ManyToManyField ordering using through?

Here is a snippet of how my models are setup: class Profile(models.Model): name = models.CharField(max_length=32) accout = models.ManyToManyField( 'project.Account', through='project.ProfileAccount' ) def __unicode__(self) return self.name class Accounts(models.Model): name = models.Ch...

SQL Server multiple many-to-many join query

I currently have a one main table with multiple other tables associated with it via many-to-many joins (with join tables). The application using this database needs to have search functionality that will print out multiple rows matching specific criteria, including all the values in the join tables. The values from the join tables also n...

How to create related records with Doctrine PHP

Hello I have modeled two classes with a many to many relationship : User and Conversation, and I can't create a the link between these two classes when I use them : class User extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('udid', 'string', 255); $this->hasColumn('nb_requetes', 'integ...

Symfony + Doctrine Many to Many relations with Linking Tables

Situation: I have 3 tables: Student, Address, StudentAddressLink As follows Note* not EXACT yaml file but you get the idea Student: column: id: blah blah name: blah blah Address: column: id: ~ street: ~ StudentAddressLink: column: id:~ student_id: ~ address_id: ~ relations: Student: ...

Entity Framework Self-Referencial Many-To-Many with Payload ( Bill of Materials BOM )

I asked this question a while back without an answer, I believe it may be the most bizarre implementation for the EF, although it is quite practical. Here is my previous post: http://stackoverflow.com/questions/2367702/entity-framework-self-referencing-hierarchical-many-to-many I've decided to ask again with the additional keyword Payl...

Need Formset for relationship model with forms for all instances of one ForeignKey

I have a ManyToMany field with a relationship model. I want a formset, filtered on one of the keys, which shows a form for each of the other keys. My guess is that a custom manager on the relationship model is the key to solving this problem. The manager would return "phantom" instances initialized with the appropriate ForeignKey when n...

Delete object and its many-to-many relation

I am trying to delete an object that sometimes has a many-to-many relation. The code I use now is: db.DeleteObject(registeredDevice); db.SaveChanges(); This ofcourse just removes the registeredDevice. But usually this device has a many-to-many relation to a project in the database. When trying to delete the device in that scenario it...

Django - Cascade deletion in ManyToManyRelation

Using the following related models (one blog entry can have multiple revisions): class BlogEntryRevision(models.Model): revisionNumber = models.IntegerField() title = models.CharField(max_length = 120) text = models.TextField() [...] class BlogEntry(models.Model): revisions = models.ManyToManyField(BlogEntryRevision...

How can I change the name of the self-referential many-to-many set using hibernate.reveng.xml?

I have a project using Hibernate on an Oracle database for which all entities are generated directly from Hibernate Tools under control of a hibernate.reveng.xml file. I have one class which has a many-to-many relationship to itself using an intermediary table, like so: PERSON: ID ... PERSON_PERSON: PARENT_ID --> PERSON.ID CHI...

Kohana: How to load all many-to-many relationships in one query

I have a database relationship that looks something like this: booking -> person <-> option -> : one-to-many <-> : many-to-many I now need to list all the persons in a booking, with all their options. Using ORM in kohana I can load all persons like this: $persons = ORM::factory('booking', $id)->persons->find_all(); I could then l...

FluentNHibernate mapping many-to-many to the same entity or how to map a graph?

Hello, I have a situation where I need to store a graph data structure in the database. This means an entity can have unlimited number of related entities of the same type (related entity can have unlimited related entities as well). I was thinking that many-to-many relationship would solve my problem. I'm trying to do mapping with F...

Django, queryset to return manytomany of self

Following regular manytomany queryset logic gives me errors. I guess since its related to self, I might need to do some extra magic, but i can't figure out what magic. model: class Entry(models.Model): title = models.CharField(max_length=100, verbose_name='title') related = models.ManyToManyField('self', related_name=...

hibernate @ManyToMany bidirectional eager fetching

I have a question which I think should be pretty common but I can't find an answer. I have 2 objects: Group and User. My classes look something like this: class Group { @ManyToMany(fetch = FetchType.EAGER) List<User> users; } class User { @ManyToMany(fetch = FetchType.EAGER) List<Group> groups; } Now, when I try to get a Use...

data model, many2many with many2one relationship

Hey, I have two types of accounts (customer and provider), I chose the single-table strategy for persistence. Customer creates Orders (one2many) and provider bids on the orders in auction style (many2many relationship, because he can bid on many orders as well as other providers). My question is, is it possible to have these relationship...

django adding a ManyToMany field/table to existing schema, related_name error

I have an existing project with models (Users and Books). I would like to add a ManyToMany(M2M) field to the existing model Books, but the syncbb command does not do this. Details: Books already has a FK field that maps to User, and I want to add a new M2M field (readers) that also maps to User. As you know, Django's syncdb only cares...

Adding audit columns to a Fluent NHibernate many-to-many junction table

I'm using Fluent NHibernate to generate a database schema from .Net entity classes. I have two classes User and Permission with a many to many relationship, and Fluent NHibernate is correctly generating a junction table UsersToPermissions in the database. As expected the junction table is storing the primary keys UserId and PermissionId...