sql - How to link a single row from a table to a whole separate table -


i have 2 tables want link, want link every individual studentid in table whole questions table.

i trying create lets me set number of questions question table individual student using studentid when student signs account can view questions have been set them. think might need add boolean questions table called [set] or can update true means student can view question.

i shall provide tables maybe explain bit more:

questions table(i think want link studentid table questions):

create table [dbo].[questions] ( [questionid]     int           identity (1, 1) not null, [actual answer]  nvarchar (50) null, [question space] nvarchar (50) null, [question type]  int           null, primary key clustered ([questionid] asc) ); 

classes table:

create table [dbo].[classes] ( [classsize] int null, [teacherid] int not null, [studentid] int not null, constraint [pk_classes] primary key clustered ([teacherid] asc, [studentid] asc), constraint [fk_classes_studentdetails] foreign key ([studentid]) references [dbo].[studentdetails] ([studentid]), constraint [fk_classes_teacherdetails] foreign key ([teacherid]) references [dbo].[teacherdetails] ([teacherid]) ); 

studentdetails table

(i don't think necessary me provide table anyway):

create table [dbo].[studentdetails] ( [studentid]     int           identity (1, 1) not null, [title]         nvarchar (50) null, [username]      nvarchar (50) null, [password]      nvarchar (50) null, [first name]    nvarchar (50) null, [last name]     nvarchar (50) null, [email address] nvarchar (50) null, primary key clustered ([studentid] asc) ); 

since have m-m relation between question , student i.e. question can set multiple students , student can have multiple questions, need intermediary table denotes question set student. this.

create table [dbo].[questionstudentassociation] ( [questionstudentassociationid] int identity(1,1) not null, [questionid] int not null references questions(questionid), [studentid] int not null references studentdetails(studentid), primary key clustered ([questionstudentassociationid] asc) ); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -