0

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

4

2 回答 2

1

If your ER diagram is intended to depict a conceptual data model, you can use generalization/specialization to present the fact that a post is one of several different types of post.

If your diagram is intended to depict a logical data model, using the relational model of data, you have a design decision to make.

One alternative is presented under this tag : .

Another alternative is presented under this tag: .

If you choose the second alternative, and you want to enforce the one-to-one relationship between the general posts table and each specialized table, check out this tag: .

In all three tags, the info tab spells out the details.

于 2013-03-30T16:38:03.273 回答
1

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.

于 2013-04-01T09:00:58.143 回答