Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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 ?

share|improve this question
    
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 at 16:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.