可以說你已經在比賽中,用戶和項目負責人的表,它可以是這樣的:
create table users
(user_id int,
constraint pk_users primary key (user_id)
...
);
create table project_leaders
(leader_id int,
constraint pk_leader primary key (leader_id),
user_id int,
constraint fk_leaders foreign key (user_id)
...
);
create table competitions
(competition_id int,
constraint pk_competitions primary key (competition_id),
competition_name varchar(128),
creator_id int,
constraint fk_competition_creator foreign key (creator_id) references project_leaders(leader_id),
created_at datetime,
...
);
現在你需要的類型和重量一表...
create table types
(type_id in,
constraint pk_types primary key (type_id),
type_name varchar (128),
...
);
create table weights
(weight_id in,
constraint pk_weight primary key (weight_id),
weight_value int,
...
);
create table types_weights
(type_weight_id int,
constraint pk_types_weights primary key (type_id_weight),
type_id int,
weight_id int,
foreign key fk_types_weights_type foreign key type_id references types (type_id),
foreign key fk_types_weights_weigh foreign key weight_id references (weight_id),
creator_id int,
competition_id,
constraint fk_types_weights_creator foreign key (creator_id) references project_leaders(leader_id),
constraint fk_types_weights_competition foreign key (competition_id) references competitions(competition_id),
created_at datetime,
...
);
現在你需要一個表在關係模型
create table competition_participants
(competition_id int,
user_id int,
type_weight_id,
constraint pk_competition_participants primary key (competition_id, user_id, type_weight_id),
constraint fk_competition_participants_competition foreign key (competition_id) references competitions (competition_id),
constraint fk_competition_participants_users foreign key (user_id) references users(user_id),
constraint fk_competiton_participants_types_weights (type_weight_id) references types_weights (type_weight_id),
created_at datetime,
...
);
加入的一切,這應該做的伎倆,現在改變模式,以符合您的規範...
明智的答案。非常感謝。我確實已經有用戶,團隊領導和比賽 - 這只是挑戰類型/權重,但我認爲你已經清除了 - 現在無論如何! – JP89
現在不要忘了投票答案,並將其標記爲正確的答案:) –
當然:)將確保我回來了一些進展爲雅! – JP89