DATABASE DESIGN
do one thing remove cid from student table and create a new table studnt_course(sid,cid) then redundancy would get off....
nice. thanks. but is there anyway we could further optimize it , i mean without having to store redundant data( like if a student takes 20 courses then we need to store the students name 20 times against the appropriate courses).
P.S: I was asked this in Capital IQ, when i gave answer same as yours he asked me remove redundancy.
surely, the new table stores sid,cid right.
suppose there is a student with sid-01 and he takes courses c01,c02,c03,c04,c05,c06,c07 and c08.
then we need to have rows and table as
sid cid
01-c01
01-c02
01-c03
.......
01-c08.
what i meant to ask is, can this redundancy be removed in any way?
I believe that the most efficient solution (as far as redundancy is concerned) is to have 3 tables:
- Anonymous September 06, 2013Student:
* sid
* name
Course
* cid
* cname
StudentCourses
* sid
* cid
This way you only store the Student name and the Course name (which is where the "heavy" data is) once.
Best,
Slavi
HiredInTech