'Two different tables, both fetch information of another one
I have two similar tables Projects and Ideas So I have a Project with his unique PID: 1, and for example an Idea with the same unique IID: 1. I'm trying to add another table called "Comments" that it's going to be used by both Projects and Ideas
Example:
Project Idea Comments
------ ----------- --------------
PID IID comment_id
title proyect_id comment_parent
eg_url eg_idea_title **Project/idea ID** // This one is my problem
So I don't know whats the best approach to differentiate if a comment belongs to a Project or a Idea.
Im thinking on create another "Objects" table, to genere really unique objects_id for whatever other table (like Project or Idea) and use that object_id to reference the comments table (or any other table that needs to be share for two or more tables)..
Objects Comments
------ -----------
object_id comment_id
obj_type (Project / Idea) comment_parent
Project/Idea ID object_id <-- Use the object ID
Solution 1:[1]
You use a reference/lookup table to attribute the file to either project or idea:
file fileProject fileIdea
------ ----------- ----------
id fileId fileId
projectId ideaId
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kermit |
