开发者

DB Schema design, table with many columns

开发者 https://www.devze.com 2023-03-31 12:13 出处:网络
I\'m designing a schema for a learner management system. I currently have LearnerDetails table which stores below categories of information.

I'm designing a schema for a learner management system.

I currently have LearnerDetails table which stores below categories of information. - login user account details - contact details and home address - learner's residency related information including nationality info, current visa details to remain in UK etc - learner's current state benefit related information - details about learner's current employment status

The problem that I have is, when all these information are represented in a single table, number of columns exceed 70 columns.

One thing that I can to do is, I can segregate information in to different tables representing the categories mentioned above and associate these tables to their parent table LearnerDetails as 1:1 relationships.

I'd like to know whether this is a reco开发者_JAVA百科mmended approach or not. In my opinion 1:1 relationships would represent a database what is over normalized. But if I didn't do this, it would result in having a huge horizontal table as my LearnerDetails table.

Highly appreciate if you could let me know your opinions/suggestions.


There is nothing inherently wrong with many columns in a table, as long you have 5NF, or at least 3NF.

But, there are quite a few examples where vertical partitioning (1::1) makes sense -- take a look at a similar question.


How wide are the columns? If your record is wider than the page size then having one wide table is a performance propblem waiting to happen.

Address is generally NOT a 1-1 relationship with person. Yes most people only have one but that is not true of everyone. Students for instcne sometimes live part time with each of their divorced parents. I would suggest that address be separated out. If you store phone numbers, those two are generally not in a 1-1 relationship. You might have a cellophone a fa xnumber a business number and a home phone (landline) number. Anything that hasa good possibility of eventually needing to be in a one-many relationship should be separated out from the start.

If you do separate out the tables and want to enforce the one-to-one relationship, yuo can either use the id from the parent table as the PK inthe child table or have a differnt Pk for the table and set-up a unique index for the FK field. Do not set-up a one-to-one realtionship without a way to enforce it in the database.


There is no problem at all to have 70 or more columns, if that's what normalisation requires. You did not mention which rdbms you use, but most suport at least 255 fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号