You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constraint FK1 foreign key(userid) references users(id) on delete cascade on update cascade
);
create view scores as
(
select rank, username, score from users U left outer join submissions on U.id = submissions.userid where (score>0 and status=0 and time=(select max(time) from submissions where status=0 and userid=U.id)) or (score=0 and ((select count(*) from submissions where userid=U.id)=0 or (time = (select max(time) from submissions where userid=U.id)))) order by score desc, time asc, username asc
);
create table chat
(
id int auto_increment,
userid int,
time int,
msg varchar(250),
primary key(id),
constraint FK2 foreign key(userid) references users(id) on delete cascade on update cascade
);
create table announcements
(
id int auto_increment,
time int,
msg varchar(500),
primary key(id)
);
-- Create admins (rank==1 means admin)
insert into users(username, password, rank) values('admin', 'onj', 1);