Which design better when use foreign key instead of a string to store a list of id

Posted by Kien Thanh on Programmers See other posts from Programmers or by Kien Thanh
Published on 2012-11-16T11:14:24Z Indexed on 2012/11/16 17:16 UTC
Read the original article Hit count: 406

I'm building online examination system. I have designed to table, Question and GeneralExam. The table GeneralExam contains info about the exam like name, description, duration,...

Now I would like to design table GeneralQuestion, it will contain the ids of questions belongs to a general exam.

Currently, I have two ideas to design GeneralQuestion table:

  1. It will have two columns: general_exam_id, question_id.
  2. It will have two columns: general_exam_id,
    list_question_ids (string/text).

I would like to know which designing is better, or pros and cons of each designing.

I'm using Postgresql database.

© Programmers or respective owner

Related posts about database

Related posts about database-design