Link to home
Start Free TrialLog in
Avatar of enrique_aeo
enrique_aeo

asked on

implementation - transact sql - many to many relationship

Hello, What is the implementation?
tblCourse(CourseID, CourseName, CourseField1, CourseField2...)
tblStudent(StudentID, FamilyName, FirstName, DoB, StudentField1, StudentField2...)
tblCourseStudent(CourseID, StudentID, PerformanceMetric1, PerformanceMetric2...)
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

enrique_aeo said:
>>Hello, What is the implementation?

What is your question?  What are you trying to accomplish?

Quick note: that table structure looks denormalized...
Avatar of enrique_aeo
enrique_aeo

ASKER

THE  CODE transact sql
enrique_aeo,

Sorry, but it is still not clear.

Patrick
tblCourse(CourseID, CourseName, --) when CourseID is primary key
tblStudent(StudentID, FamilyName, ..) when StudentID is primary key
tblCourseStudent(CourseID, StudentID, ...) when CourseID and StudentID are foreign key
something like I do in transact sql code?
my question is, as it resolves a many to many relationship in transact sql code?
ASKER CERTIFIED SOLUTION
Avatar of GRayL
GRayL
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is no code to form the third table.  You should create a form with combo boxes for both Courses and Students as well as some way of entering all the performance metrics (combo or list box)
Try:
SELECT 
	 C.*
	,CS.*
	,S.*
FROM
	tblCourse C
INNER JOIN
	tblCourseStudent CS ON C.CourseID = CS.CourseID
INNER JOIN
	tblStudent S ON CS.StudentID = CS.StudentID

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
tblCourses and tblStudents are an eschema Intranet, these tables already exist. The new table is tblCoursesStudents,  therefore would only have to make the code table creating tblCoursesStudents or I do something extra in the tables tblCourses and tblStudents
Somehow you have to get the info about what students are taking what course into the the tblCoursesStudents.  As I suggested earlier, the best way would be to use a form designed for that purpose.  You have to create the table and then use the form to populate it.
Thanks, glad to help