I'am trying to find out the best database design and try to stick with data integrity by using Foreign Keys. But I'm stuck right at the beginning because of limit relations between tables with FK to 1.

Currently, I'm using this schema:

enter image description here

What I really want, is to somehow connect all necessary tables with routes and use FK, if it's possible.

It mean's whenever I add a new category item, it should create a new route in routes table.
When I delete a specific category item, it should remove a route from routes database. As simple as that, but I'm sure I'am doing very wrong here.

Can someone suggest me what DB Schema I should use to stick with it ?

  • Automatically adding a route could be done with a BEFORE trigger, but it seems wrong. As for the delete, check out CASCADE. – Alain Collins Jun 2 '14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.