简体   繁体   中英

Achieving SQL 3NF normalisation

I'm trying to achieve 3NF using the data I have but I'm getting confused. These are the tables I have:

FACULTY table    DEPARTMENT table        STUDSGROUP table         STUDENT table
FACULTY_ID       DEPARTMENT_ID           STUDSGROUP_ID            STUDENT_ID
FACULTY_NAME     DEPARTMENT_NAME         ACADEMIC YEAR            STUDENTS_NAME
FACULTY_DEAN     HEAD OF DEPARTMENT      COURSE/SPECIALITY        STUDENTS_GROUP
                                                                  COURSE/SPECIALITY 
                                                                  DOB/DATE OF BIRTH

I am thinking I can do it like this below, though I think I'm not right.

FACULTY table
FACULTY_ID,PK
DEAN

DEPARTMENT table
DEPARTMENT_ID,PK
FACULTY_ID,fk
DEPARTMENT_NAME
HEAD OF DEPARTMENT


STUDSGROUP table
STUDSGROUP_ID, pk
ACADEMIC YEAR
SPECIALITY

STUDENTS table
STUDENT_ID, pk
FACULTY_NAME,FK
STUDSGROUP_ID,FK
FIRST_NAME
LAST_NAME
DOB

Normalization requires that you know how the various parts of the schema are related. Up to 3NF and BCNF (almost, but not quite the same thing — though you'd be hard-pushed to find a practical example of 3NF that is not also in BCNF), the most important feature is the functional dependency.

Another key point is 'conservation'; you shouldn't lose columns altogether. For example, your original Faculty table has an ID number, a name and a dean. Your revised version is missing the faculty name; that is a bug in your redesign.

You've identified that each department belongs to a faculty, which seems plausible enough.

Your revised Student Groups table seems to be the same as in the original. That's probably OK, though maybe the course/speciality part of that means that a student group is associated with a department, and hence a faculty. If so, then the you might need a courses/specialities table that identifies the course/speciality and the department, leaving the student group to identify a particular year group within the course/speciality.

Your original students table has a course/speciality and also a student group; this leaves open the possibility that the data will say Student X is doing Archaeology in the Students table, but the Student Group indicates that Student X is doing Music. Is that allowed? If not, would you be best served by just having the Student Group in the Students table, leaving that to identify course/speciality, and year, and department, and hence faculty? Your revised schema adds a faculty ID to the students table (but does remove the course/speciality); that still leaves opportunities for conflict within the data.

Do you need a table to identify valid academic years? Possibly not. Should there be a table for staff, so that you can identify deans and department heads. Can the dean of a faculty be a department head? Of departments outside their faculty?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM