I am new to SQL.
I would like to ask when I have an entity with another weak entity. How to create a table in a situation where, if I delete the main object, the weak object will also be deleted?
A foreign key with on delete cascade should do the trick:
on delete cascade
CREATE TABLE primary_entity ( id numeric PRIMARY KEY, -- some data fields ); CREATE TABLE weak_entity ( id numeric PRIMARY KEY REFERENCES primary_entity(id) ON DELETE CASCADE, -- some data fields );
Source: https://habr.com/ru/post/1205006/More articles:an anonymous field of type golang of type map - structiOS 8: get resource from Cocoa Touch Framework - iosInsert channel into structure - goJava abstract for processing two objects, like the same in a tree - javaHow can I find the total amount of RAM that my system uses C - cto find maven version and install MAVEN_HOME in ubuntu - javaWCompact Size ClassHow to check device language in Android? - javaAdding a synchronous caching mechanism to an asynchronous transparent method - c #What determines the memory address for global variables. Compiler or operating system? - cAll Articles