Search code examples
sqlsql-serverdatabase-designentity-relationshipnormalization

should i separate table different types contents or not?


I am working on an ASP.Net website documentation. The website looks like c-sharpcorner.com that enables users to post Articles, questions, job opportunities, job request. while i am designing the website's ER diagram, i gets confused should i put all user's types of posts(articles,quests,hobs....etc) in one table and just make a type attribute to differentiate between them or should i separate each post type in an separated entity.. what is better? it is the same for me, but i need an expert to advise me what is the best way to handle that issue. thanks


Solution

  • There is no out of the box answer for your question because it’s solution specific.

    Ask yourself following questions and you’ll get the answer yourself.

    How many null fields are going to exist in the table? If you have column that is going to be used for posts only that means that column will be null for all other answer types. If you have a have a lot of null values in your database than it’s not really a good design.

    How likely is that requirements going to change over time and that you’ll need to customize or more post types? The more likely you’ll need to customize later the better you’ll go with the separate table for each post type.

    What is the relative number of posts for each type? If you’re going to have 90% answers that are one type and only 10% for all other types then it might be a good idea to separate tables and avoid performance issues when working with the 10%...

    Again, there is no right or wrong answer here. You need to analyze your specific solution some more to come up with what’s best for you specifically.