many-to-many

Generic many-to-many relationships

I'm trying to create a messaging system where a message's sender and recipients can be generic entities. This seems fine for the sender, where there is only object to reference (GenericForeignKey) but I can't figure out how to go about this for the recipients (GenericManyToManyKey ??) Below is a simplified example. PersonClient and Comp...

How do you insert an entity for a many-to-many relationship? (entity framework)

If I a many-to-many relationship between Users and Roles and I have an instance of a User entity and several Role Ids can I insert a relationship between the two types of entities without having any other Role data and without doing a select on the Roles first? Update: I might not have been clear enough. I don't have an instance of a ...

JPA @ManyToMany Writing On Create But Not Update

Hi gang, My team has two classes, User and Store, related by JPA @ManyToMany annotations. The relevant code is below. When creating a new User object and setting its stores, life is good. But we're seeing some unexpected behavior when trying to update User objects through our Struts 2 / Spring web UI. (These problems do not occur whe...

Fluent NHibernate Has Many to Many Convention Questions

I am new to fluent nhibernate and nhibernate. I want to write a fluent nhibernate autopersistence convention to handle creating the many to many mappings for my entities. This is what I have right now: using System; using FluentNHibernate.Conventions; using FluentNHibernate.Mapping; namespace Namespace { public class HasManyToMan...

problem with a Many to many relations in Entity framework

I have 3 entities -Direction -City -GeoPosition each Direction have a Geoposition, and each City have a collection of Geopositions (this represent a polygon) I have 5 tables -directions -cities -geopositions -directionsgeopositions -citiesgeopositions and EF entities is this each entity have function imports for insert, update, and...

NHibernate Many to many mapping with additional columns in the mapping table

There are two tables Person and Address. I have a mapping table PersonAddressMap which contains an additional column IsCurrent other than the two foreign keys (no explicit primary key column). I have created three mapping classes one each for Person, Address and PersonAddressMap. I need to access all the Addresses of a Person and also ac...

Designing classes from One-Many table with extra fields

How do I model any additional properties from One-Many relationships in the database back into classes? For example I have 3 tables Model, Manager and Model_Manager. The Model_Manager table has ModelId, ManagerId and two extra properties - Percentage and Owner. At first I created two classes Manager and Model and the Model class contai...

Many-to-Many Association To Same Model with ActiveRecord?

I'm following this tutorial which is working splendidly for has_many :through relationships. I've got normal things like category_product working. However, I am not able to conceptualize this situation (nor get it to work): I have a Category that has related Categories. Since every category can have N categories... first off, is this ac...

Many-to-many insert using LINQ to SQL and ASP.Net MVC

I have two Tables: Products(ProductID, ProductName) and Categories(CategoryID, CategoryName) with a many-to-many relationship between Products and Categories ProductsCategories(ProductID, CategoryID) How Can I Implement a view that enables a user to Add and Edit one product with many categories using Asp.Net Mvc and LINQ to SQL? ...

Many-To-Many MS Access Form With Checkboxes for All Options

I'm working on a Microsoft Access application for a summer camp to track which entities have signed up for which activities. There is a form for editing an entity's information. I would like to add to that form a list of all activity options. By each option should be a checkbox. When the checkbox by an option is checked, a entry should e...

How do I use Navigational Properties as Primary Keys in Entity Framework (.Net 4.0)?

I'm trying out the Model First approach introduced in Entity Framework with VS2010/.Net 4.0, and now I don't really know how to do this. I start out with the following Entities: Contact Event ******* ***** Id (Int32, not null, pk) Id (Int32, not null, pk) Name (Name, not null)...

Can a many-to-many join table have more than two columns?

I have some tables that benefit from many-to-many tables. For example the team table. Team member can hold more than one 'position' in the team, all the positions are listed in the position db table. The previous positions held are also stored for this I have a separate table, so I have member table (containing team details) positions...

Zend Many to Many Relationship

I want to retrieve all the data from 3 tables users , properties and users_properties. So I decided I would use the manytomanyRowset. But to my surprise I get the data from the properties and users_properties table but no data from the users table. Why is that? I need some columns from the users table is there a way to tell the manytom...

NHibernate - Many-to-Many Cascading Delete

Hi! I have defined a many to many relationship between two classes. Event and Person (defined in a separate database table person_event). Now, suppose I want to delete a person, so all its related associations with events must also get deleted from the person_event table. In other words, I want cascade ON DELETE. Lets consider a sce...

Custom Managers and "through"

Hi I have a many-to-many relationship in my django application where I use the "add" method of the manager pretty heavily (ie album.photos.add() ). I find myself needing to store some data about the many-to-many relationship now, but I don't want to lose the add method. Can I just set a default value for all the additional fields on th...

SQL: Many-To-Many table AND query

Hello, First - apologies for the fuzzy title, I could not find a better one. I have table with the following structure (simplification): EmpID DeptID 1 1 1 2 2 1 3 2 4 5 5 2 This table represents a many-to-many relationship. I'm interested in finding all the EmpIDs that are related to a specific group of De...

NHIBERNATE: Map Many-To-Many association (With attached Schema Image & mapping Files ...)

Hi! Please, I'm trying to map many-to-many association in order to use cascading Delete. Model Description: A View contains a List of Group (using the DB Association Table Asso_Project_Manager_Group_View). And a Group contains a List of Project Manager (using the DB Association Table Asso_Project_Manager_Group). Find DB Schema Image H...

How to add/remove many-to-many relation with entity framework by entity key?

I tried: using (Entities e = new Entities()) { EntityKey key = new EntityKey("Entities.Users", "UserId", 20); User user = new User { EntityKey = key}; Role role = e.Roles.FirstOrDefault(); //role.Users.Attach(user); //throws (when uncommented...) InvalidOperationException: //The object being attached to the source ob...

NHibernate many-to-many mapping

Hi, I am having an issue with many-to-many mapping using NHibernate. Basically I have 2 classes in my object model (Scenario and Skill) mapping to three tables in my database (Scenario, Skill and ScenarioSkill). The ScenarioSkills table just holds the IDs of the SKill and Scenario table (SkillID, ScenarioID). In the object model a Scen...

How to insert rows in tables having many-to-many relation in linqtosql

I am new to linqtosql. I have a database schema where, An employee can belong to more than one team and team can belong to more than one employee. So actually I have a, Employee table: EmpID(PK),EmpName, etc.. EmployeesTeam table: EmpID(FK),TeamID(FK) (These two make composite PK) Team table: TeamID(PK),TeamName,etc I added rows t...