many-to-many

How to perform a many-to-many filter using ReferenceProperty in Google App Engine?

This is my model, Players and Clubs. As a Club can have many players and a player can have many clubs (in its carrer), I used a many-to-many relationship: class Club(db.Model): name = db.StringProperty() link = db.StringProperty() class Player(db.Model): name = db.StringProperty() link = db.LinkProperty() class...

PHP doctrine many-to-many last identifier problem

Guys, I have small problem when trying to create many-to-many link in doctrine. I have simple scenario here: User and Role with many-to-many relationship defined. $user = new User(); $user->username = 'greg'; $user->save(); $role = new Role(); $role->name = "Administrator"; $role->save(); $role_user = new Role_User(); $role_user->R...

How to insert record to an association table with PRADO ActiveRecord?

Hi! I have 2 many-to-many tables and 1 association table for them: 1. Student StudentID (PK) 2. NextOfKin NextOfKin (PK) 3. StudentNextOfKin StudentID, NextOfKinID (PK) FK StudentID References Student(StudentID) FK NextOfKinID References NextOfKin(NextOfKinID) With the following codes, i am able to create a new NextOfKin record in D...

mysql many to many relationship

Been reading the tutorial How to handle a Many-to-Many relationship with PHP and MySQL . In this question I refer to the "Database schema" section which states the following rules: This new table must be constructed to allow the following: * It must have a column which links back to table 'A'. * It must have a column which links ...

How should I setup my database to allow for followers/following like Twitter?

I have groups on my website, and would like users to follow groups, and groups to follow users. I was wondering how does the following/follower works, in terms setting out in a MySQL table and referencing users? I'm very confused!! ...

entity framework 4 many to many update

I have 3 tables - User (Id, Name) Roles (Id, Name) UserRoles (UserId, RoleId) I think they are self explanatory. How do I update an entry (UserId and RoleId) in UserRoles? context.User.Roles gives me the list of roles but how do I update them? Thank you. ...

Django: how to aggregate / annotate over a many-to-many relationship?

I have a Person model and a Tag model, with a m2m between them. I need to extract the tag which is connected to the most records within a given Person queryset, together with the count. Is there an elegant, efficient way to extract this using the Django ORM? Better yet, is there a way to get the entire tag distribution through some a...

SQL query: How to count frequency over a many-to-many relation?

I have a table for blogposts and a table for tags, with a many-to-many relation between them. How can I extract the most frequent tag across a subset of blogposts? (e.g. only those from the past year) Is there a way to extract the frequencies of all the tags associated with the blogposts subset? Thanks Edit: my schema: CREATE TABLE ...

How to config Many-to-many with condition, in Sqlalchemy

I'm use sqlalchemy 0.6.4. I have 2 classes: Question and Tag, they are many-to-many. class Question(Base): __tablename__ = "questions" id = Column(Integer, primary_key=True) deleted = Column(Boolean) ... tags = relationship('Tag', secondary=r_questions_tags) class Tag(Base): __tablename__ = "tags" id = Co...

Entity Framework 4 Code-First many to many insert

I'm using code-first pattern for database layer. I have two POCO classes: public class Order { [Key] public int OrderId { get; set; } public virtual ICollection<Item> Items { get; set; } // other fields } and public class Item { [Key] public int ItemId { get; set; } public virtual ICollection<Order> Order...

Problem with NHibernate not detecting other associations when all-delete-orphan is set on a M:N relationship

Here's the scenario: I have 3 objects called Person, VideoGame, and Store. One Person can have many VideoGames One VideoGame can belong to many Persons Same M:N relationship is between Store and VideoGames In the DB, the only thing besides these entities are two simple join tables PersonsVideoGames and StoresVideoGames. Assume ever...

How should I insert/update/delete large lists in mysql?

I am trying to figure out the best way to handle inserting/updating/deleting large lists. Specifically, my users need to select large lists of products and they will get reports on those items every night. To oversimplify it, here is the data model (a simple many to many) ~ 5000 records total +----------+------------+ | user_id | us...

HELP! MySQL Join Many to Many + PHP

Hello everybody! And how to write MySQL Join and PHP? Or you can make another? ... Examples: Table 1: movie_id | movie_title 1______ | title_movie_1 2______ | title_movie_2 3______ | title_movie_3 Table 2: genre_id | genre_title 1______ | title_genre_1 2______ | title_genre_2 3______ | title_genre_3 Table 3: id | movie_id...

How to update many-to-many related objects with Entity framework 1 & MySQL?

Hello, I have such a problem. I'm using EF1 with VS2008 SP1 & MySQL with MySQL Connector/Net 6.3.4 My database schema looks like this: CREATE TABLE IF NOT EXISTS `credential` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; CREATE T...

doctrine2 remove ManyToMany relationship

I have a Group Entity with the following class member and mapping: /** * @ManyToMany(targetEntity="Group", cascade={"persist"}) * @JoinTable(name="groups_children", * joinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id", unique=t...

How do I query a many to many relationship model? - Google App Engine

Here are my models: class User(db.Model): id = db.StringProperty(required=True) created = db.DateTimeProperty(auto_now_add=True) updated = db.DateTimeProperty(auto_now=True) name = db.StringProperty(required=True) email = db.StringProperty() class Page(db.Model): id = db.StringProperty(required=True) created...

PHP: How to make a list of film and genre (example) - MySQL Join Many-to-Many (want?) and the PHP?

Hello everybody! How to make a list of film and genre - MySQL Join Many-to-Many (should I?) And the PHP? Or do the other way? Examples: In MySQL: Table 1: movie_id | movie_title 1______ | title_movie_1 2______ | title_movie_2 3______ | title_movie_3 Table 2: genre_id | genre_title 1______ | title_genre_1 2______ | title_genre_2 ...

Automatically removing associations when deleting entities in NHibernate

I have the following entities: namespace NhLists { public class Lesson { public virtual int Id { get; set; } public virtual string Title { get; set; } } public class Module { public virtual int Id { get; set; } public virtual IList<Lesson> Lessons { get; set; } public Module() { Lessons = new List<Lesson>...

Creating a new many-to-many table

I have a database Class_Books which links ISBNs (from Books table) to Class_ID's (from Classes table). I'm changing my Books table so the primary key is a Book_ID (autoincrement INT) instead of the ISBN. Is there a way to update Class_Books so it uses Book_ID now? ...

Asking help for many-to-many properties persistence in Hibernate

Hi Buddies, Here I have a question about persist many-to-many properties. Example: class Movie { /** * @hibernate.bag cascade="save-update" table="movie_genre" * @hibernate.collection-key column="ITEM_ID" * @hibernate.collection-many-to-many column="GENRE_ID" class="Genre" * @hibernate.collection-cache usage="r...