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
2
votes
1 answer

Entity Framework doesn't delete children, instead sets references to null

I have the following situation: First the only relevant table/class (all auto generated from DB (MySQL)): The relevant part of the edmx file:
OschtärEi
  • 2,255
  • 3
  • 20
  • 41
2
votes
3 answers

Is it possible to custom the delete on cascade of CakePHP?

I have a table with logs related to the Post ones and i dont want its data to be deleted when i delete a Post. In the other hand, i want to delete all the comments of the Post as well as other data. I have been taking a look at the documentation but…
Alvaro
  • 40,778
  • 30
  • 164
  • 336
2
votes
2 answers

hibernate does not generate on delete cascade in mysql for mapping of a HashMap

I have a problem generating a mysql schema with hibernate. I've searched for an answer to my problem but I haven't found it (many similar problems but not exactly mine). I need to map a State diagram into mysql (or transition table), and delete the…
2
votes
1 answer

Hibernate cascade delete orphan

I have 2 entities: News and NewsComment @Entity @Table(name = "news", schema = "city") public class News { private Set comments = new HashSet(); ... …
user1480528
  • 37
  • 2
  • 8
2
votes
1 answer

Django 1.4 Multiple Databases Foreignkey relationship (1146, "Table 'other.orders_iorder' doesn't exist")

I have a Foreign Key from one model into another model in a differente database (I know I shouldn't do it but if I take care properly of Referential Integrity it shouldn't be a problem). The thing is that everything works fine...all the system does…
2
votes
2 answers

What's wrong with the query?

What's wrong with the query? delete from categories c left join categories_products cp on cp.category_id = c.id left join products p on p.id = cp.product_id left join images i on i.object_id = cp.product_id where c.id = 3 and i.site_section =…
dearmisterrobot
  • 164
  • 1
  • 5
  • 16
2
votes
2 answers

SQL DELETE (Cascading DELETE vs. TRIGGERS vs. "Manual"-DELETE)

I'm currently working with SQL Server Management Studio 2005 and I'm facing a bit of a problem, but first an extract (the important one) of my DB-schema: imghack link to the image I want to delete from the test table and everything it is connected…
Rufus
  • 121
  • 1
  • 1
  • 9
2
votes
1 answer

How does cascade delete works in many to many relationship in coredata works?

Say, we have 2 entities : Parents and children. When a parent is deleted, then all the children are erased too. Great. Now we have entities called lover. Each individuals can "love" many other individuals and be loved by many. What happen if an…
user4951
  • 32,206
  • 53
  • 172
  • 282
2
votes
1 answer

On delete cascade android 2.2

I have 2 tables: Table 1- create table table1(_id integer primary key, content text not null ); Table 2- create table table2(_id integer primary key, id_parent integer, content text not null , CONSTRAINT [FK_table2_id_parent] FOREIGN KEY…
2
votes
3 answers

How to improve deletion times in Oracle for a self-referencing table

In our Oracle 11g database we have a table, that has a primary key I_Node (int) and also a column called I_Parent_Node (int) that references back to another record in the same table. The root node has I_Parent_Node = null. In this way we form a…
Dave Ludwig
  • 460
  • 1
  • 4
  • 14
1
vote
2 answers

Hibernate deleting related tables using delete HQL?

I am new to hibernate. This is my master visaInquiry bean mapping that has many one-to-many and many-to many relation mapping through hibernate. Now to delete the record I am using this query Transaction ts=session.beginTransaction(); …
Rakesh Goswami
  • 205
  • 1
  • 4
  • 21
1
vote
2 answers

How to automatically delete rows in a table when the corresponding rows in a 1 to 1 table are deleted?

I have two different kinds of document. One is organized by folder. The other is organized by client. Here is the table structure, in mysql: Table docs ID title Table folderDocs docID -> docs(ID) folderID -> folders(ID) ON DELETE CASCADE Table…
user1031947
  • 6,294
  • 16
  • 55
  • 88
1
vote
1 answer

Is truncation of parent table restricted even when child table is empty?

I can use delete from table_name which works. Why not truncate?
Pop Stack
  • 926
  • 4
  • 19
  • 27
1
vote
1 answer

MySQL on delete cascade doesn't work...I'm using mac os x lion and sequel pro

I cannot make it work. An example from http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id) ) ENGINE=INNODB; CREATE TABLE child (id INT, parent_id…
alvizouri
  • 83
  • 2
  • 7
1
vote
1 answer

ASP.NET SQL with linq-to-entites turn off cascade delete

I have an asp.net web application in visual studio 2010. I am connected to an sql server using linq-to-entites objects and need to find out how to turn off cascading-deletes when i delete an object via a grid-view. Anybody know?