1

I'm trying to transform the following relation to 3NF but can't figure it out. The relation is (a student can only have 1 major):

STUDENT (StuID, StuName, Major), Primary Key = {StuID}

I tried the following transformation, splitting it into 2:

STUDENT (StuID, StuName)
MAJOR (StuID, Major)

But I don't think it is correct because there are still anomalies. For example, if the school decides to introduce a new Major, they can't add it unless a student has selected that major.

Can someone guide me how I should proceed with this problem.

Second try:

STUDENT (StuID, StuName, MajorID)
MAJOR (MajorID, Major)
5
  • Think logically. The major has to exist so that the student can take it.... So it has to be an entity.
    – Philᵀᴹ
    Commented Oct 23, 2014 at 23:54
  • I posted my second try above. I introduced MajorID. I think it's ok now right? Unless I'm missing something
    – user50887
    Commented Oct 24, 2014 at 1:01
  • will there be new entry made in MAJOR in future?
    – vijayp
    Commented Oct 24, 2014 at 3:10
  • Could be, it is not specified. That's why the first one doesn't work, because if the school decides to offer a new major, it can't be added to the table until a student chooses it.
    – user50887
    Commented Oct 24, 2014 at 3:14
  • and student can choose two major at a time?
    – vijayp
    Commented Oct 24, 2014 at 3:16

1 Answer 1

1

I think this is better choice when student can choose multiple Major at a time.

STUDENT (StuID, StuName)
MAJOR (StuID, Major)

You Second Try will be a better choice when student can choose only one Major at a time

STUDENT (StuID, StuName, MajorID)
MAJOR (MajorID, Major)

Now one more step, I can think of here is, as Major value is some fixed set of variable(limited in number), This will gives the option to add new Major and student can choose more than one Major at a time.

Student (StuID, StuName)
Major (StuID, MajorID)
MajorLookup (MajorID, Major)
4
  • Student can only choose 1 major.
    – user50887
    Commented Oct 24, 2014 at 3:31
  • 1
    @user50887, Go with your second try, that is the best choice now.
    – vijayp
    Commented Oct 24, 2014 at 3:33
  • In the scenario when a student can choose multiple majors, you said: STUDENT(StuID, StuName) and MAJOR (StuID, Major). But is this in 3NF? Because there is a multivalued variable. StuID appears in both relations, so you need to update StuID in two places, no?
    – user50887
    Commented Oct 26, 2014 at 0:39
  • Yes, it is 3NF, as let say a student choose 2 major, then there will be only one entry in STUDENT table and two entry in MAJOR table. on update, it depends what you need to update only StuName then update only STUDENET table, and similar for MAJOR table, for updating both you need to update both table. If STUDENT table has 1-2 columns only, then you may go for adding mutiple reords in STUDENT table with column MAJOR added there. But Possibly you may have more columns in STUDENT table like DateOfBirth etc...
    – vijayp
    Commented Oct 26, 2014 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.