one-to-many

Two attributes sharing the same OneToMany relationship to one entity Symfony2

梦想与她 提交于 2019-12-07 05:11:05
问题 Let's first describe my situation. I am using Symfony2 and I have a problem with a relationship between my entities. I have two entities that are linked together. The two entities are AssociationQuestion and AssociationPossibleAnswer . I am currently creating a questionary software where one would have to link one possible answer on the left to another one possible answer on the right, such as in the following example: Currently, I'm planning on having two attributes that are arrays in class

mysql one-to-many query with negation and/or multiple criteria

柔情痞子 提交于 2019-12-07 04:21:42
问题 I thought a query like this would be pretty easy because of the nature of relational databases but it seems to be giving me a fit. I also searched around but found nothing that really helped. Here's the situation: Let's say I have a simple relationship for products and product tags. This is a one-to-many relationship, so we could have the following: productid | tag ======================== 1 | Car 1 | Black 1 | Ford 2 | Car 2 | Red 2 | Ford 3 | Car 3 | Black 3 | Lexus 4 | Motorcycle 4 | Black

CoreData to-many add error

核能气质少年 提交于 2019-12-07 03:32:06
问题 Not sure what I'm doing wrong here. School has a to-many to Student, and Student has its inverse. A little test code as follows: @class Student; @interface School : NSManagedObject @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSOrderedSet *students; @end @interface School (CoreDataGeneratedAccessors) - (void)insertObject:(Student *)value inStudentsAtIndex:(NSUInteger)idx; - (void)removeObjectFromStudentsAtIndex:(NSUInteger)idx; - (void)insertStudents:(NSArray *

How to render one to many relationships to XML with PostgreSQL

烈酒焚心 提交于 2019-12-07 03:10:04
问题 I have several many to many relationships in my schema. For example, a package has many taskgroups, taskgroups in turn have many tasks. All tables are linked together via many to many tables, holding for instance the primary key of package and the primary key of taskgroup. (I know this is not strictly needed, since XML is one to many, but I couldn't think of a better structure). Is it possible to get the query result as XML, reflecting the one-to-many structure? So, the result should be like

How to get a Builder object from rows related to pivot - Laravel

为君一笑 提交于 2019-12-07 00:26:29
I'm trying to get all the "books" that one user have: but I can't do it how I need. I use the following code: /*Gets all books from the user whose id is 1*/ $books= User::find(1)->books(); That return to me an Collection object; but I need a Builder object, as I get when I use the "select" method. /* This code return me a "Builder" object */ Books::select(array('id', 'name', 'type')); I need the Builder instead of Collection because I using Bllim/Datatables on my project and this package just accept a Builder object... If I send it a Collection its throw me the next error (500 - Internal

Hibernate (JPA) multiple @OneToMany for same model

怎甘沉沦 提交于 2019-12-07 00:21:16
问题 I have two models. @Entity public class Student { @Id @GeneratedValue(strategy=GenerationType.AUTO) protected long id; @? protected Address homeAddress; @? protected Address schoolAddress; } @Entity public class Address { @Id @GeneratedValue(strategy=GenerationType.AUTO) protected long id; @? protected List<Student> students; } What JPA/hibernate annotations do I need to put above homeAddress , schoolAddress and students to make the association work? Of course I've tried many things and

JPA/Hibernate bidirectional many-to-one results in StackOverflowException

懵懂的女人 提交于 2019-12-06 23:14:27
问题 I have entities User and GrantedRole that have a bidirectional one-to-many relation. When I try to add a GrantedRole to the Set in User, there is no exception thrown, but when I debug the variables for the User and GrantedRole object have a description that reads com.sun.jdi.InvocationException occurred invoking method. The different fields for the variables can be read while debugging, but when I select the roles field in User or the user field in GrantedRole I get the same description as

saving pictures in Core Data in 'to-many relationship' environment

为君一笑 提交于 2019-12-06 16:15:30
问题 I'm working on my small project which take pictures and save them, very simple, using Core Data. I have two entities; one is 'Person' and the other is 'Image'. the relationship from Person to Image is to-many and from Image to Person I got inverse relationship as well. All I need at the moment is to add multiple number of images (taken from iphone camera or chosen from library) to one Person entity . I'd like to know whether there is any kind of sample code that deals with to-many

SubSonic 3 - Simple repository - One to many relations

拜拜、爱过 提交于 2019-12-06 15:56:35
It's the first time I use Subsonic. Let say I have those classes : public class Store { public int Id { get; set; } public String Name { get; set; } } public class Employee { public int Id { get; set; } public String Name { get; set; } } An employee is related to a store with is hired date. This means that in the database I will have a middle table With StoreId, EmployeeId, StartDate, EndDate UPDATE An employee can work to the StoreA from 2009-01-01 to 2009-04-04 and work for StoreB from 2009-04-05 to ... And I don't want that my data table repeat all the information of my employee each time

MongoDB : where is the limit between “few” and “many”?

拥有回忆 提交于 2019-12-06 14:47:10
I am coming from the relational database world (Rails / PostgreSQL) and transitioning to the NoSQL world (Meteor / MongoDB), so I am learning about denormalization, embedding and true links. It seems that, in many cases, choosing between various database schemas comes down to the number of documents that will be "related" to each others. In this video series , the author distinguishes: one-to-many relationships from one-to-few relationships many-to-many relationships from few-to-few relationships So, I am wondering: where is the limit between few and many ? I guess there may not be a hard