cascading-deletes

SQL Server 2008 - Multiple Cascading FK's - Do i need a trigger?

浪子不回头ぞ 提交于 2019-12-01 04:11:57
问题 I have a 1..* relationship between User and Post . (one user has many posts) Post has a FK called "UserId", which maps to the "UserId" field on User table. I tried to set this FK as Cascade UPDATE/DELETE, but i get this error: 'Users' table saved successfully 'Posts' table - Unable to create relationship 'FK_Posts_Users'. Introducing FOREIGN KEY constraint 'FK_Posts_Users' on table 'Posts' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or

EF 4.1 RC: Weird Cascade Delete

妖精的绣舞 提交于 2019-11-30 22:44:19
I have to admit, the features of EF 4.1 RC Codefirst, DataAnnotations and FluentAPI are still overwhelming to me. Sometimes I really don't know what I am doing ;-) Please see the following POCOs: public class Country { [Key] public Guid ID { get; set; } [Required] public virtual Currency Currency { get; set; } } public class Currency { [Key] public Guid ID { get; set; } public virtual ICollection<Country> Countries { get; set; } } The general idea: Every country needs to have a currency. But a currency does not need to be assigned to a country at all. If you let EF create the corresponding

How to use DELETE ON CASCADE on many-to-one relation

瘦欲@ 提交于 2019-11-30 18:56:23
May someone help me out. I'm trying something, but I'm (too) new to (my)SQL. I use two tables: Items and Categories. Table Items has a field with foreign key: category_id. I want the table Categories to be kept tidy. So when no item in Items is of category X in Categories, the category X should be deleted from Categories. How do you establish that. I guessed by using DELETE ON CASCADE, but so far it was only deleting corresponding items from Items when I deleted a categorie from Categories. Thanks a lot for helping me! ON DELETE CASCADE is a way of deleting a row when a row it references is

How to use DELETE ON CASCADE on many-to-one relation

℡╲_俬逩灬. 提交于 2019-11-30 03:51:32
问题 May someone help me out. I'm trying something, but I'm (too) new to (my)SQL. I use two tables: Items and Categories. Table Items has a field with foreign key: category_id. I want the table Categories to be kept tidy. So when no item in Items is of category X in Categories, the category X should be deleted from Categories. How do you establish that. I guessed by using DELETE ON CASCADE, but so far it was only deleting corresponding items from Items when I deleted a categorie from Categories.

iPhone Core Data: Cascading delete across a many-to-one relationship

青春壹個敷衍的年華 提交于 2019-11-30 00:11:38
I have two classes A and B with a many-to-one relationship from A to B (multiple A objects may reference the same B). The question is, if the delete rule on the A side is Cascade, will B be deleted only when the last referencing A is deleted or will it be deleted the first time an associated A is deleted. The delete rule for the B side of the relationship is Nullify if that matters. Also, I read in the Core Data docs that the Optional flag matters in some cases. But it wasn't clear how the relationships they were illustrating related to my case. They were talking about a containment case (B is

Entity Framework object graph deletion with Breeze

坚强是说给别人听的谎言 提交于 2019-11-29 17:45:36
I am encountering a recurring problem that just makes no sense, and hoping someone (in the Breeze team?) can shed some light. The following model illustrates the entities in question. As you can see, I'm adhering pretty strictly to Entity Framework conventions in my property names, and as a result, if I check in SQL the cascade on delete rules are set by EF code first when it creates the db. Now, when I try to delete a BusUnit manually in SQL, the delete cascades correctly and the corresponding BusUnitDimensions are also deleted, as it should be. Likewise, if I delete a Dimension in SQL, the

CASCADE Delete in many-to-many self-reference table

梦想的初衷 提交于 2019-11-29 15:13:25
Table DISPLAY_TAB below is a self-reference table that can contain both parent and child tabs. A parent tab can have multiple child tabs and a child tab can belong to multiple parents. I'd like to establish a CASCADE DELETE relationship between main table and relationship table DISPLAY_TAB_GROUPING so when either parent or child tab is deleted - relationship is automatically deleted as well (just relationship, not actual tab record). So I am creating a FOREIGN KEY constrain on DISPLAY_TAB_GROUPING for fields TAB_ID_R_1 and TAB_ID_R_2 tables, referencing TAB_ID in DISPLAY_TAB table. And it

EF4.1 Code First : How to disable delete cascade for a relationship without navigation property in dependent entity

为君一笑 提交于 2019-11-29 07:33:03
问题 Let's say I have these two very basic entities: public class ParentEntity { public int Id; public virtual ICollection<ChildEntity> Childrens; } public class ChildEntity { public int Id; public int ParentEntityId; // Foreign Key public virtual ParentEntity parent; // [NOTWANTED] } For some reasons, I don't want the ChildEntity to hold a reference back to his parent. I just want it to keep the ParentEntity id but nothing more. Up until now, no problem, I just delete the [NOTWANTED] line, and

What is the recommended equivalent of cascaded delete in MongoDB for N:M relationships?

ε祈祈猫儿з 提交于 2019-11-29 03:04:14
Assuming the following "schema/relationship" design what is the recommended practice for handling deletion with cascade delete like operation? Relational Schema: +---------+ +--------+ | Student |-*--------1-[Enrollment]-1--------*-| Course | +---------+ +--------+ MongoDB: +---------+ +--------+ | Student |-*----------------*-| Course | +---------+ +--------+ Given this classic design of enrollment of students to courses, having a collection of courses in students and vice versa seems to be an appropriate data model when using MongoDB (that is nothing for the relationship/enrollment table).

Core Data Relationships cause save error after delete

会有一股神秘感。 提交于 2019-11-29 02:00:28
问题 This question is probably a long shot. I can't figure out the errors I'm getting on my core data project when I save after I delete an entity. I have two main entities that I work with, an Outfit, and an Article. I can create them with no problem but when I delete them I get the follow error log: For the Outfit: 2009-09-22 20:17:37.771 itryiton[29027:20b] Operation could not be completed. (Cocoa error 1600.) 2009-09-22 20:17:37.773 itryiton[29027:20b] { NSLocalizedDescription = "Operation