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

Hibernate - Many to One relationship, possibility to delete last shared reference automatically?

I have a many-to-one relationship and I like that the last shared reference should get deleted by hibernate automatically. The questions are is this is supported by hibernate? if not can I achieve this by adding some kind of api callbacks from…
megloff
  • 1,400
  • 4
  • 27
  • 44
3
votes
1 answer

Hibernate many to many with extras columns delete parent

I have two entities purchase and product, they have many to many relationship let's call purchaseProduct her is the DDL for purchaseProduct CREATE TABLE purchaseproduct ( idpurchaseproduct serial NOT NULL, idpurchase integer, idproduct…
abdou amer
  • 819
  • 2
  • 16
  • 43
3
votes
1 answer

Use 1:n DeleteActions

How is it possible to use DeleteActions for 1:n table-relations? Example: Table A ("id") ('foo') ,('bar') ,('blup') Table B: ("id", "tableAId1", "tableAId2") (1, 'foo', 'blup') ,(2, 'bar', 'foo') I have two relations on tableB: TableB:tableAId1 ->…
Nico
  • 1,175
  • 15
  • 33
3
votes
1 answer

Tree deletion with NHibernate

I'm struggling with a little problem and starting to arrive at the conclusion it's simply not possible. I have a Table called Group. As with most of these systems Group has a ParentGroup and a Children collection. So the Table Group looks like…
Tigraine
  • 23,358
  • 11
  • 65
  • 110
3
votes
2 answers

nhibernate many to many deletes

I have 2 classes that have a many to many relationship. What i'd like to happen is that whenever i delete one side ONLY the association records will be deleted with no concern which side i delete. simplified model: classes: class Qualification { …
3
votes
5 answers

How can I delete from three tables with foreign keys?

I want to be able to choose a groupID and do a cascading delete through three tables which are found in a MS SQL server database. The tables look like the following: table 1 - GROUP ------------------------------------------- groupID | description…
Chris
  • 6,272
  • 9
  • 35
  • 57
3
votes
1 answer

Delete on cascade in other direction

Is there a way to use the ON DELETE CASCADE option in the other direction? (DB2) I have a (A one-to-many B) relation and delete one item from B and I want that the item A which is a foreign key from B also will be deleted. Is that possible ?
user3117357
  • 45
  • 1
  • 3
3
votes
0 answers

NHIbernate parent-child issue: foreign key set to null instead of deletion

Searched high and low for an answer but can't make this work with all the examples I've tried. I have a certain bi directional parent child relationship. Parent ("Case") holds a collection of children ("CaseNotes") and is mapped as…
Igor Minin
  • 31
  • 1
3
votes
1 answer

Oracle Delete Statement: how many rows have been deleted by cascade delete

I'm executing a statement like DELETE FROM USER WHERE USER_ID=1; In SQLDeveloper. As the user is referenced in many tables (for example the user has an order, settings, ...) we activated ON DELETE CASCADE so that we do not have to delete each and…
patrickuhlmlann
  • 342
  • 2
  • 4
  • 14
3
votes
2 answers

SQL Delete vs. Cascade

I'm creating a contact management system that records a company's contact details, contact person, campaign, submitted proposals by the company, and donation. One company can have many contact people, can submit many proposals in many campaigns,…
3
votes
1 answer

Many-to-Many Relations with 'code first' in Entity Framework 5 (EF5 - final release) wtih VS2012

I had invest now one day to find a solution wihtout success. I like to create a simple Many to Many relation. For that I've created two Models: A Player class where i will have the 'Turnaments' navigation property to see which turnaments has visit a…
3
votes
1 answer

Build foreign key graph query dynamically from given table

I have a delete issue at the moment. We do not have permission to enable Cascade delete on the record. I have User table where userId is references in about 20 different table. I want to be able to write a dynamic query which would go and…
3
votes
1 answer

How can i get id of cascade deleted (or marked for delete) items in sqlalchemy?

When I cascade delete one item, I want get list of all deleted items id (primary key) including ids of deleted children. Is it possible? My class looks like: class Example(Base): __tablename__ = 'example' id = Column(Integer,…
2
votes
2 answers

Foreign Key CASCADE DELETE for table with multiple parents?

I am very new to foreign keys and CASCADE operations, and am wondering about the following scenario: Let's say I have two completely different parent tables (HUMAN and ALIEN) with completely different data. Now, what I want to do is create a child…
user1193694
  • 121
  • 1
  • 8
2
votes
1 answer

Deleting linked data across tables in PostgreSQL

I'm looking for the best way to handle deleting linked data across three PostgreSQL tables (technically more, but it's the same idea). The three tables are agency, address, and agency_address. An agency can have multiple addresses so the…
jshrc
  • 187
  • 8