entity-relationship

iOS Core Data how to properly initialize entity relationships?

扶醉桌前 提交于 2019-12-06 11:48:27
I have a one to many relationship in my core data model. I need to create a new entity and save it. The entity has a one to many relationship which generated the following code: - (void)addRelationshipEvent1:(NSSet *)values; - (void)removeRelationshipEvent1:(NSSet *)values; . NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity]; ApplicationRecord *newManagedObject = (ApplicationRecord*)[NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext

Symfony Doctrine entity friend hasFriend followers

[亡魂溺海] 提交于 2019-12-06 10:34:15
问题 I need to set follower, following (myFriends) hasFriend logic to my project. column "odobera" means "following" to example nick(id user) odobera (following to this user). User (25) is following user(37). Requests table: User entity: /** * @ORM\OneToMany(targetEntity="TB\RequestsBundle\Entity\Requests", mappedBy="odobera") */ protected $followers; /** * @ORM\OneToMany(targetEntity="TB\RequestsBundle\Entity\Requests", mappedBy="nick") */ protected $myFriends; public function __construct() {

One-to-many relationship: Update removed children with JPA 2.0

家住魔仙堡 提交于 2019-12-06 08:46:36
问题 I have a bidirectional one-to-many relationship. 0 or 1 client <-> List of 0 or more product orders . That relationship should be set or unset on both entities: On the client side, I want to set the List of product orders assigned to the client; the client should then be set / unset to the orders chosen automatically. On the product order side, I want to set the client to which the oder is assigned; that product order should then be removed from its previously assiged client's list and added

Why is a specific cardinality not allowed in the ERD?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 07:53:06
In every tutorial on entity relationship diagrams, I read that specifying a fixed cardinality for a relationship is not allowed. Only an informal comment on the ERD may clarify that the number of pilots is exactly 2 . So, for example, a relationship between flights and pilots where each flight has exactly 2 pilots present, would have to be represented as: <flight> 0..N <------> 1..N <pilot> rather than <flight> 0..N <------> 2 <pilot> My notation is 0..N = optional, many; 1..N = mandatory, many, 1 = mandatory, one. Is this restriction universal? What's the reason behind it? EDIT: clarified my

Is there a nosql store that also allows for relationships between stored entities?

一个人想着一个人 提交于 2019-12-06 07:20:21
问题 I am looking for nosql key value stores that also provide for storing/maintaining relationships between stored entities. I know Google App Engine's datastore allows for owned and unowned relationships between entities. Does any of the popular nosql store's provide something similar? Even though most of them are schema less, are there methods to appropriate relationships onto a key value store? 回答1: It belongs to the core features of graph databases to provide support for relationships between

Problem with SaveChanges() Entity Framework 4.1

懵懂的女人 提交于 2019-12-06 06:01:52
I am having problem with saving the changes to database. I am updating the model A in my controller, however when I save the changes using SaveChanges() I end up having a duplicated item in database for B. After the UpdateModel() is called I inspected the Bs property and it was as I expected however right after the SaveChanges() is called if I inspect the Bs property I will see that the Id is completely different (new Id and new entry). My class is similar to this: public class A { [HiddenInput(DisplayValue = false)] public int AId { get; set; } public string Name { get; set; } public virtual

Symfony and Doctrine - cannot remove item from collection (Many-to-Many relation with extra field)

走远了吗. 提交于 2019-12-06 04:49:52
Good day everyone! I have a question about collection persistence in Symfony and Doctrine The short version I can add an item to collection (persist) via form, but can not remove (remove). The logics I need a possibility to add users to business trips. Each added user must have text description (like a objective for business trip). In fact, i have 3 entities: BusinessTrip BusinessTripUser (stores linked User id, BusinessTrip id and text field "description") User (vendor bundle entity) The problem As i already said above - i cant remove BusinessTripUser from collection $users in BusinessTrip. I

Entity Framework - Read Lock on Record

南笙酒味 提交于 2019-12-06 04:40:41
问题 I'm calling same database from different applications using Entity Framework. However, when one application is reading/updating a record, I do not want other applications to read that data. I tried with the following sample code; however, they are still able to read the record. Any suggestion OR different approaches will be highly appreciated! using (Entities context = new Entities(ConnectionString)) { DBTable entity; do { entity = context.DBTable .Where(item => item.IsLock == false)

C# Entity Framework should we set a relationship by using the POCO.Id or just the POCO?

落爺英雄遲暮 提交于 2019-12-06 03:42:36
I have a situation in a service method where assigning a POCO as a child object of another POCO does not work as expected. I am using Entity Framework 4. public void ChangeOrderCurrency(Currency currency) { order.CurrencyId = currency.Id; order.Currency = currency; // other stuff related to exchange rates etc } Which is more correct to use to set the relationship? order.CurrencyId = currency.Id or order.Currency = currency ? In this current code which passes all unit tests, occasionally the line order.Currency = currency will set both order.CurrencyId and order.Currency to NULL It makes more

Extended Entity-Relationship Model to tables (subclasses)

一世执手 提交于 2019-12-06 03:09:17
In the EER model there are subclasses entities. I was wondering what's the way to implement that in a real SQL Table or if there is any guide that might help me out to understand how to implement entities subclasses into tables that would help. Thanks Martin Fowler's book Patterns of Enterprise Application Architecture covers solutions for subclassing tables: Single Table Inheritance Class Table Inheritance Concrete Table Inheritance These correspond to the options in the answer from @spencer7593, without being tied to Java & Hibernate. The Hibernate documentation has discussion of the options