many-to-many

UML class model how to model many to many relationship

余生长醉 提交于 2019-12-03 06:57:49
问题 I have read several tutorials on what a UML model should contain and what not. As a developer I always think in terms of a relational data model where you could never have a many to many relationship between tables. Now with a UML class model, I've read that if they don't provide added value, you could just skip the linktables. However I've also read a tutorial where examples where given using data inside tables and was strongly suggesting to picture each class as a simple table while

Django Bi-directional ManyToMany - How to prevent table creation on second model?

微笑、不失礼 提交于 2019-12-03 06:50:15
问题 I have two models, each has a shared ManyToMany, using the db_table field. But how do I prevent syncdb from attempting to create the shared table, for the second model? class Model1(models.Model): othermodels = ManyToManyField('Model2', db_table='model1_model2', related_name='model1_model2') class Model2(models.model): othermodels = ManyToManyField('Model1', db_table='model1_model2', related_name='model2_model1') It's working great in my dev environment, because some of the tables got created

How do I handle table relationships with the repository pattern?

假如想象 提交于 2019-12-03 06:38:10
I'm implementing the repository pattern as part of an ASP.NET MVC site. Most examples I've seen of repositories are fairly simple. For example here's a typical abstract repository interface. public interface IRepository<TEntity> { IQueryable<TEntity> All(); TEntity FindBy(int id); TEntity FindBy(Expression<Func<TEntity, bool>> expression); IQueryable<TEntity> FilterBy(Expression<Func<TEntity, bool>> expression); bool Add(TEntity entity); bool Update(TEntity entity); bool Delete(TEntity entity): } It's clear to me how you would use a repository like this to add, update, delete, or get entities

Using EntityRepository::findBy() with Many-To-Many relations will lead to a E_NOTICE in Doctrine

岁酱吖の 提交于 2019-12-03 06:23:12
问题 For a Symfony2 project I had to create a relationship between a blog post and so called platforms. A platform defines a specific filter based on the domain you use to view the site. For example: If you join the site by url first-example.com, the site will only provide blog posts, which are connected to this specific platform. To do so, I created two entities Post and Platform. Afterwards I mapped them together with a Many-To-Many relationship. I'm trying to retrieve data via this Many-To-Many

Django 1.8 - Intermediary Many-to-Many-Through Relationship - What is the consequence of where 'ManytoManyField' is used?

*爱你&永不变心* 提交于 2019-12-03 06:13:20
An example Many-to-Many through relationship in Django: class First(models.Model): seconds = models.ManyToManyField(Second, through='Middle') class Middle(models.Model): first = models.ForeignKey(First) second = models.ForeignKey(Second) class Second(models.Model): Following the documentation on intermediary models , only one model of the pair to be related contains the ManytoManyField , model First in the example above. Is this correct? If so, which model should contain the ManytoManyField field? Are there any differences in using the relationship from either end depending on where the

Algorithm that searches for related items based on common tags

懵懂的女人 提交于 2019-12-03 06:10:24
问题 Lets take StackOverflow questions as example. Each of them has multiple tags assigned. How to build an algorithm that would find related questions based on how many common tags they have (sorted by number of common tags)? For now I can't think about anything better than just selecting all questions that have at least one common tag into an array and then looping through them all assigning number of common tags to each item, then sorting this array. Is there more clever way of doing it?

Saving Many to Many relationship to database in Symfony2

只愿长相守 提交于 2019-12-03 05:54:02
In my Symfony2 project I have two related entities: Users and Favorites. They have a many-to-many relationship. My application works as follows: In my Twig-page I have an few items with a button 'Add to Favorites'. When you click the button my controller saves the item_id in the Favorites column. But then I want to save the user who added the item to his favorites and here my application fails. The User and the favorite exist but the joincolumn between Users and Favorites remains empty. I also don't receive any kind of errors. Here is my code: Entity Users class Users implements

What is the proper way to deal with adding/deleting many-to-many relationships in REST?

有些话、适合烂在心里 提交于 2019-12-03 05:31:28
Let's say we have an entity that contains a list of users on the server, and we want to expose this as rest. What is the proper way to do it? My first guess is something like this: /entity/1/user/5 We can use PUT for updates and DELETE for deletes? Is this right? I went to wikipedia where it talks about rest, and their view of it is that everything is only 1 level deep. So maybe they want you to use PUT/POST and give the entire JSON graph and update the entire thing all at once? Your example is a perfectly valid approach. However in many cases a User can exist outside of the context of just

How do I set up a facet search with a many to many relationship using Sunspot?

我们两清 提交于 2019-12-03 05:17:43
问题 I haven't implemented a search feature before and feel a bit stuck. I have a Sunspot search feature which finds results based on keywords - this works great - but I now want to implement the multi select facet feature, but I can't even seem to figure out how to set-up a basic facet search. I have a many to many relationship (in rails not in real life): Class People has_many :skills, :through => experience (and vice versa etc) Class People < ActiveRecord::Base has_many :skills, :through =>

Django Admin: Many-to-Many listbox doesn't show up with a through parameter

試著忘記壹切 提交于 2019-12-03 05:11:15
问题 I have the following models: class Message(models.Model): date = models.DateTimeField() user = models.ForeignKey(User) thread = models.ForeignKey('self', blank=True, null=True) ... class Forum(models.Model): name = models.CharField(max_length=24) messages = models.ManyToManyField(Message, through="Message_forum", blank=True, null=True) ... class Message_forum(models.Model): message = models.ForeignKey(Message) forum = models.ForeignKey(Forum) status = models.IntegerField() position = models