I have 2 tables, customer and address. Customer has column address with FK referencing to table address.
create table customer ( id int(11) not null primary key, ... address int(11) null, constraint fk_customer_address foreign key (address) references address (id) on update cascade on delete cascade, )
create table address ( id int(11) not null primary key, ... )
I want to have address id in customer table, because in future there will be more tables referencing to address table (Users.address, Bussiness.address, etc) and one table for all addresses because of the same format.
When I delete row in customer table, address row stays in DB. Is it possible to use this FK relation to delete row in address table, or do I have to delete it manually (programmatically)?
Does this mean that when I delete row from address, customer row is deleted as well?
Yes, it does.