many-to-many

JPA : many-to-many - only one foreign key in the association table

I mapped two classes in a ManyToMany association with these annotations : @Entity @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class TechnicalItem extends GenericBusinessObject implements Resumable{ @SequenceGenerator(name="TECHNICAL_ITEM_ID_GEN", sequenceName="TECHNICAL_ITEM_ID_SEQ") @Id @Column(n...

Indexing SET field

I have two entities A and B. They are related with many to many relation. Entity A can be related up to 100 B entities. Entity B can be related up to 10000 A entities. I need quick way to select for example 30 A entities, that have relation with specified B entities, filtered and sorted by different attributes. Here how I see ideal solu...

Doctrine Many to Many

Hello, I have a question about Doctrine ORM M:M. I built some tables like this: -User +id +name -Group +id +name I want to link these table via a new table with Doctrine: In Group class: $this->hasMany('User as Users', array( // I'm wondering what I can fill here 'refClass' => 'UserGroup' )); and in th...

Fluent NHibernate: mapping complex many-to-many (with additional columns) and setting fetch

I need a Fluent NHibernate mapping that will fulfill the following (if nothing else, I'll also take the appropriate NHibernate XML mapping and reverse engineer it). DETAILS I have a many-to-many relationship between two entities: Parent and Child. That is accomplished by an additional table to store the identities of the Parent and C...

How to describe m2m triple-join table in model (Django)

My question is pretty much the same as this question, except that ALL relationships should be many-to-many. I have the following classes in my models.py (somewhat simplified): class Profile(models.Model): # Extending the built in User model user = models.ForeignKey(User, unique=True) birthday = models.DateField() class...

Pre/post delete events aren't fired on refclass (many-to-many) in doctrine.

Is this a bug in Doctrine, or my wrong interpretaion? PS: Pre/post save events are fired correctly. ...

With database table design, Is there an advantage of using special naming convention for a Many-to-many table (a junction table)?

Whenever there is a many-to-many relationship, I think there will be immediately a many-to-many table needed (also called a junction table). Is there any advantage of using special naming convention for these tables, as opposed to the other 1 to many tables? Or are there popular special naming conventions used by companies designing da...

Fluent many-to-many: Deleting one end does not remove the entry in the relation table

I have two classes (Parent, Child) that have a many-to-many relationship that only one end (Parent) knows about. My problem is that when I delete a "relation unaware" object (Child), the record in the many-to-many table is left. I want the relationship to be removed regardless of which end of it is deleted. How can I do that with Fluent...

NHibernate: Many-to-many relationship with field in the relationship table

I'm scratching my head; I have a Car table and a Customer table that have a many-to-many relationship. In this relationship table I want to add a column that can tell me what kind of relationship this is; is the customer testdriving the car, do he want to buy the car, ect. What I want to end up with is a class Car object that holds a col...

Many To Many NHibernate

Hello guys. I'm having some problems with NHibernate when it comes to mapping many to many relationships, specially this one. I have a Category table, which each parent can have as many childs as it needs, and it can be also a parent. When i try to select something from category table, i get an error: ERROR: 42601: syntax error at or ...

many-to-many mapping in NHibernate

I'm looking to create a many to many relationship using NHibernate. I'm not sure how to map these in the XML files. I have not created the classes yet, but they will just be basic POCOs. Tables Person personId name Competency competencyId title Person_x_Competency personId competencyId Would I essentially create a List in each POC...

Best way to handle Many-to-Many relationships in PHP MySQL

I am looking for the best way to handle a database of many-to-many relationships in PHP and MySQL. Right now I have 2 tables: Users (id, user_name, first_name, last_name) Connections (id_1, id_2) In the User table id is auto incremented on add and user_name is unique, but can be changed. Unfortunately, I don't have control over the us...

many-to-many query

Hello, guys! I have a problem and I dont know what is better solution. Okay, I have 2 tables: posts(id, title), posts_tags(post_id, tag_id). I have next task: must select posts with tags ids for example 4, 10 and 11. Not exactly, post could have any other tags at the same time. So, how I could do it more optimized? Creating temporary tab...

Fluent Nhibernate napping to existing database with primary key in joining table of a many to many relationship

I have an existing database with a many to many relationship however the joining table has a primary key ID and 2 foreign keys to do the join. Is it possible to configure the mapping files to handle this? at the moment i am stuck. Thanks ...

nhibernate many to many deletes

I have 2 classes that have a many to many relationship. What i'd like to happen is that whenever i delete one side ONLY the association records will be deleted with no concern which side i delete. simplified model: classes: class Qualification { IList<ProfessionalListing> ProfessionalListings } class ProfessionalListing { ...

EF 4.0 - Many to Many relationship - problem with deletes

My Entity Model is as follows: Person , Store and PersonStores Many-to-many child table to store PeronId,StoreId When I get a person as in the code below, and try to delete all the StoreLocations, it deletes them from PersonStores as mentioned but also deletes it from the Store Table which is undesirable. Also if I have another person w...

What are appropriate ways to represent relationships between people in a database table?

I've got a table of people - an ID primary key and a name. In my application, people can have 0 or more real-world relationships with other people, so Jack might "work for" Jane and Tom might "replace" Tony and Bob might "be an employee of" Rob and Bob might also "be married to" Mary. What's the best way to represent this in the databa...

Find Object in Many-to-Many Szenario - Grails

Hello, i got this situation: - class user with hasMany Roles and belongsTo Roles - class Role with hasMans User how can i get the roles belongs to a user, object user is given, how can i get objects in a many-to-many szanario? findByX doesn't work, it's affect just one table, but i need a "find" or something else to find Object overal...

how to map SubclassMap and HasManyToMany in Fluent NHibernate

Hi everyone. My problem is fluent nhibernate mapping a many to many relationship, they end up referencing a non existent Id. public UserMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x.Password); Map(x => x.Confirmed); HasMany(x => x.Nodes).Cascade.SaveUpdate(); HasManyToMany<Node>(...

listing objects from ManyToManyField

i am trying to print a list of all the Conferences and for each conference, print its 3 Speakers. in my template i have: {% if conferences %} <ul> {% for conference in conferences %} <li>{{ conference.date }}</li> {% for speakers in conference.speakers %} <li>{{ co...