Questions tagged [cascading-deletes]

The concept of SQL databases deleting rows that refer (via a foreign key) to a deleted row.

The concept of SQL databases deleting rows that refer (via a foreign key) to a deleted row. The deletion is performed recursively and enabled with the ON DELETE CASCADE property of the foreign key.

587 questions
0
votes
2 answers

Handling database record deletions with several levels of offspring

We've got a database that generally has this structure: Master Record Table id (pk) MasterRecordId <-- constrained to be unique Children/Siblings (2nd Generation, if you will): Table1 ( table1ID (pk), MasterRecordID (fk)) Table2 ( …
peacedog
  • 1,415
  • 20
  • 32
0
votes
1 answer

Replace T-SQL triggers with Entity Framework 4.0 code?

Entity Framework 4.0 project. I am currently doing my cascading deletes using an INSTEAD OF DELETE trigger. Is there a way to just do this in my Data Model code? I thought about adding my Data Context class via partial class. Then using…
sheamus
  • 3,001
  • 4
  • 31
  • 54
0
votes
1 answer

Cascade Delete from DB, by some params("WHERE value=..."), using hibernate

In Bean class there is this annotation: class User { @OneToMany(targetEntity = Feedback.class,mappedBy = "user",cascade = CascadeType.ALL,fetch = FetchType.LAZY) private List feedbacks; ... …
Yurii
  • 1
0
votes
1 answer

Delete data in Mysql data base table

How can I delete data form a table with out delete other table data? Is that possible Null value for foreign key in MySql data base table? I want to delete one Department without delete other tables data like (shifts, remote_login_id, skills).…
user881703
  • 1,111
  • 3
  • 19
  • 38
-1
votes
1 answer

How to soft delete using an AFTER DELETE Trigger in mysql that does not cascade delete the child table, but updates it in mysql

So my parent table, which is a lookup table shares an attribute with my child table (foreign key). So my goal is to have an after_delete trigger, or any trigger that will update the foreign key in the child table when a row in a parent table is…
-1
votes
1 answer

how is cascading implemented in sql?

I have a tableA with primary key which acts for a foreign key for tableB. How does sql delete rows from tableB if a row is deleted form tableA, assuming ON DELETE CASCADE is on. Does SQL performs full-table scan for tableB? And what if foreign…
Rajat Aggarwal
  • 392
  • 3
  • 16
-1
votes
2 answers

relationship row to be deleted on cascade delete

I have the following entities in a one-to-many relationship: @Entry class Parent { @Id @GeneratedValue(strategy=GenerationType.AUTO) private int id; ... @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch =…
ash__999
  • 161
  • 1
  • 1
  • 11
-1
votes
1 answer

Mapping by code in NHibernate does not delete child elements in many to one mapping

I've got the following two C# classes: public class Pet { public virtual string Id { get; set; } public virtual string Name { get; set; } } public class PetOwner { public virtual string Id { get; set; } public virtual Pet Pet {…
Quintonn
  • 770
  • 8
  • 29
-1
votes
1 answer

Cascade delete in many-to-many tables

Assume a set of mailing lists in which individuals may be members of more than one list. I've set up a join table: members -> members2lists <- lists If the user wants to remove a member from one list only, it would seem necessary only to delete the…
magnol
  • 344
  • 3
  • 15
-1
votes
1 answer

How to set up foreign key constraint in MySQL for cascading DELETE?

Searched, but more confused now then when I started. I have 2 tables, AlertsTable and AlertRecipientsTable. I'd like to add a cascaded delete that says when an AlertRecipientID is deleted (the person was removed), I want it to automatically delete…
Source Matters
  • 1,110
  • 2
  • 15
  • 35
-1
votes
2 answers

Why 'Delete from table' ignoring foreign key constraints?

I have tables: authors and rewards (one to many relations). And I would like make next rules: reward has link to author_id; restrict deletion reward if it has author_id foreign key; when I delete the author, then I want to cascade deletion rows…
Nikolas
  • 2,322
  • 9
  • 33
  • 55
-1
votes
1 answer

Deleting child entity from set in parent class

I am trying to attach image files to an entity called product. I can create a product along with the image pretty well but when i try to delete an image i get the following error. HTTP 500 - Request processing failed; nested exception is…
-1
votes
1 answer

Delete register with a stored procedure with foreign key

Im new with SQL Server, i have programmed several stored procedures and i have the next problem. For example, i have 2 tables (Role and User), and when i try to delete a role, logically the procedure shows me the error (547) because there are a…
-2
votes
2 answers

Delete Cascade without explicitly referring to all dependencies

I'm building a small db-cleaner app for a QA sql server database. Naturally, I need to delete table rows with dependencies on them. T-SQL cascading abilities are very limited, so I've tried using NHibernate to simplify matters. But, the only way I…
Tomata
  • 239
  • 1
  • 13
-2
votes
1 answer
1 2 3
39
40