mysql - One column references on multiple different tables -
think of platform-wide commenting-system. comment can added users profile, website section, comment or x other things.
that means comment has "addressee_id" , addressee_id can reference on different tables.
- comments (id, adresseee_id, ..., ...)
- sections (id, ...)
- users (id, ...)
what best way define on table join?
three possible ways:
denormalization remove other tables , add x columns "comments"-table problem: lot of empty fields.
another table "pages" page_ids. each table gets column "page_id" fk on pages.id. here have make x joins each request. sounds expensive.
comments-table gets column "addresse_type" here have implement if/else logics query expensive , not easy maintain.
what suggest?
thanks phil
Comments
Post a Comment