3 ms·
Say you have a super basic setup: user = {user_id, email} order = {order_id, user_id} order.user_id is a foreign key to user.user_id. That's a perfectly v
by berkle4455 4y ago
Say you have a super basic setup:
user = {user_id, email}
order = {order_id, user_id}
order.user_id is a foreign key to user.user_id. That's a perfectly valid and reasonable way to organize things.
Enabling RDBMS-enforced foreign key constraints is the issue. It slows everything down dramatically.
- vecter 4y agoI see, thanks. Basically just store the foreign keys yourself as columns in relevant tables and perform the joins in SQL without having the DB enforce FK integrity for every insertion/update/delete. Would it be fair to say that read speeds are unaffected by this?
- berkle4455 4y agoYes. Quite literally the only difference is not enabling foreign key constraints. Read speeds unaffected correct.
- kgeist 4y ago>It slows everything down dramatically How slower is it really? MySQL automically creates indexes for foreign keys so I don't think it slows down "dramatically", just an additional indexed retrieval? Do you know of any benchmarks which show the difference?