| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Is this bad design ?
If you refer to the solution I proposed:
Change a mother (mid) to invalid:
DELETE FROM ValidMother WHERE mother_id = mid
-- delete will fail if this mother has children (as intended)
Change a mother (mid) to valid:
INSERT INTO ValidMother(mother_id) VALUES (mid)
WHERE NOT EXISTS( SELECT * FROM ValidMother WHERE mother_id = mid)
-- the where not exists part can be dropped if you ensure that mid was
-- invalid before
Tables where:
Mother( mother_id primary key, etc_fields )
-- all mothers
ValidMother( mother_id primary key + foreign key ref Mother(mother_id)) -- "valid mother" ids
Child( mother_id foreign key ref. ValidMother(mother_id), more_fields)
Fabian
ben brugman wrote:
>>>But then the application has to be changed. >> >>No, it doesn't. A simple view serves the application well. >> >>
![]() |
![]() |