将数据库规范化为3NF [英] Normalizing a Database up to 3NF
问题描述
规范化数据库; orignally它conatin列如姓名,Phoneno,EmailAddress,地址,技能
因为每个学生可能有更多技能。
1 NF:
Studentid(PK)FirstName LastName Phoneno EmailAddress StreetName City
1 F1 L1 88889 b@gmail.com westend pune
2 F2 L2 8888 a@gmail.com Eastend Mumbai
skillid(PK)skillname studentid(FK)
1 Java 1
2 .Net 2
3 Android 1
4甲骨文1
你可以指导我应该是我的2NF和3NF正常形式:
将技能(PK)需要删除所以数据库是否在2NF?
每次我去采访时我都没能写数据库规范化到3NF
normalizing Database; orignally it conatin column like Name,Phoneno,EmailAddress,Address , skill
As each student may have more skill.
1 NF:
Studentid(PK) FirstName LastName Phoneno EmailAddress StreetName City
1 F1 L1 88889 b@gmail.com westend pune
2 F2 L2 8888 a@gmail.com Eastend Mumbai
skillid(PK) skillname studentid(FK)
1 Java 1
2 .Net 2
3 Android 1
4 Oracle 1
Can u guide me what should be my 2NF & 3NF Normal form:
will skillid(PK) need to remove so database to be in 2NF?
Each time as i go to interview & i failed to write databse normalization upto 3NF
推荐答案
此处 [ ^ ]是一个列表。如果我在采访中得到了很多,我会记住表格(实际上,我是这样做的),然后问他们你的意思是标准还是博伊斯 - 科德的正常形式?我打赌有一半人问你,不知道这意味着什么。
要达到第二范围,你要删除适用于表格多行的数据子集并将它们放在单独的表格中。
要获得第三范式,请删除与主键无关的任何列。
第二次正常:
从第二张表中删除技能ID。创建一个连接表,如果两个学生具有相同的技能,则技能在表格中一次,并在加入表中加入两次。
您的数据意味着更多一个学生可以拥有相同的电子邮件。如果这是真的,那么我想这需要考虑因素,但他们肯定更有可能拥有相同的地址或电话号码,因此它成为一个问题,你想要多么精细。
我在这里看不到任何直接违反第三范式的内容,这是我怀疑你的面试官知道他们想要你的想法的原因之一。
Here[^] is a list. If I was getting this in interviews a lot, I would both memorise the forms ( actually, I did that any how ), and ask them 'do you mean standard or Boyce-Codd normal form' ? I bet half the people asking you, won't know what that means.
To get to second normal you remove subsets of data that apply to multiple rows of a table and place them in separate tables.
To get to third normal form you remove any columns that are not related to the primary key.
Second normal:
remove the skill id from the second table. Create a joining table so if two students have the same skill, the skill is in table a once, and joined to twice in the joining table.
Your data implies more than one student can have the same email. If this is true, then I guess that would need to be factored out, but they are surely more likely to have the same address or phone number, so it becomes a question of how granular you want to be.
I don't see anything here that directly violates the third normal form, which is one reason that I doubt your interviewers know as much as they want you to think.
这篇关于将数据库规范化为3NF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!