I am currently creating a database, it allows a user to upload a publication, which is stored in a table called paper, it stores the paper_id, title, abstract filename and topic_id .I have a table called topic which has topic_id and topic_name which i use for the user to select a topic for their publication. However i want the user to be able to select at least 3 topics, is this possible using this system? I have run out of ideas of how to do it and help would be greatly appreciated
Share
Don’t store
topic_idin thepapertable. Instead, create another normalized (many-to-many) table which linkstopic_idtopaper_id.This will allow you to store as many topics per paper as necessary.
To retrieve the topics for a paper, use:
It is just about never a good idea to attempt to store multiple values in one column (such as a comma-separated list of
topic_idin thepapertable). The reason is that in order to query against it, you must useFIND_IN_SET()which drives up the complexity of performing joins and makes it impossible to utilize a column index when querying.