January 30, 2012 at 9:08 am
I am using MS SQL SERVER 2005 and for application logic and user interface using C#
I have designed a database having tables:
STUDENT table
(STUDENT_ID(PK),STUDENT_NAME)
STUDENT_ID = 1 STUDENT_NAME = SN1
STUDENT_ID = 2 STUDENT_NAME = SN2
STUDENT_ID = 3 STUDENT_NAME = SN3
COURSE table
(COURSE_CODE(PK), COURSE_NAME)
COURSE_CODE = CC1 COURSE_NAME = CN1
COURSE_CODE = CC2 COURSE_NAME = CN2
COURSE_CODE = CC3 COURSE_NAME = CN3
##STUDENT table & COURSE table exhibits many-to-many relation
CLASS table ##junction table
(CLASS_GRADE, STUDENT_ID, COURSE_CODE)
CLASS_GRADE = 1 STUDENT_ID = 1 COURSE_CODE = CC1
CLASS_GRADE = 2 STUDENT_ID = 2 COURSE_CODE = CC2
CLASS_GRADE = 3 STUDENT_ID = 3 COURSE_CODE = CC3
Now I want a table showing the name of the students and the course taught in an individual class.
User is asked to enter the class_grade and according to the user input, list of the students enrolled for that class
and the course taught in that class should be displayed.
January 30, 2012 at 10:15 am
pseudocode...
select from Class
join course
join student
where class_grade = somevalue
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 30, 2012 at 10:18 am
Homework?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply