Open tyeung2017 opened 7 years ago
and you should use mentor id as a foreign key
Yeah so just to add this, your database schema is very flawed, it is very static and non - scale able. What if you add another mentor.
It could all be done in 3 tables:
Table 1: Questions - This would be a table of the questions (singing, hair, etc) that all have id's Table 2: Mentors - this would be a table of the mentors, each with an id Table 3: Votes - This would have question id and winning mentor id and (losing mentor id if you wanted)
You then might have to do some joins and things to get some statistics, but non of it would be extremely complicated
may be instead of
CREATE TABLE singing( id SERIAL PRIMARY KEY, mentor_id INTEGER NOT NULL, rating INTEGER DEFAULT 0 NOT NULL, shireen INTEGER DEFAULT 0 NOT NULL, mario INTEGER DEFAULT 0 NOT NULL, mavis INTEGER DEFAULT 0 NOT NULL, lubes INTEGER DEFAULT 0 NOT NULL, lawson INTEGER DEFAULT 0 NOT NULL, judy INTEGER DEFAULT 0 NOT NULL, jack INTEGER DEFAULT 0 NOT NULL, suha INTEGER DEFAULT 0 NOT NULL, reem INTEGER DEFAULT 0 NOT NULL, yvonne INTEGER DEFAULT 0 NOT NULL, zooey INTEGER DEFAULT 0 NOT NULL, finn INTEGER DEFAULT 0 NOT NULL, dan INTEGER DEFAULT 0 NOT NULL );
Maybe something like this: CREATE TABLE singing( id SERIAL PRIMARY KEY, mentor_id INTEGER NOT NULL, rating integer NOT NULL
and get back the info of a particular mentor by joining two tables