Hi,
I can't decide which of the following two designs to adopt:
Code:
Design 1
CREATE TABLE scores (
userid MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
subject_id CHAR(1) NOT NULL,
done1 MEDIUMINT(8) UNSIGNED,
correct1 MEDIUMINT(8) UNSIGNED,
done2 MEDIUMINT(8) UNSIGNED,
correct2 MEDIUMINT(8) UNSIGNED,
done3 MEDIUMINT(8) UNSIGNED,
correct3 MEDIUMINT(8) UNSIGNED,
PRIMARY KEY (userid, subject_id),
);
Code:
Design 2
CREATE TABLE scores (
userid MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
subject_id CHAR(1) NOT NULL,
level ENUM('1', '2', '3') NOT NULL DEFAULT '1',
done MEDIUMINT(8) UNSIGNED,
correct MEDIUMINT(8) UNSIGNED,
PRIMARY KEY (userid, subject_id, level),
);
Assuming the number of levels is definitely fixed at 3 and there are 10 subject ids.
With Design 1, every new member requires the insertion of 10 rows (because the level information is already built into each row).
With Design 2, every new member requires the insertion 30 rows (10 rows for each level, so 10 x 3 gives 30 rows).
Should I choose Design 1 because it's less work on the database with only 10 insertions?
Thanks in advance
