Avatar of ahashash
ahashash
 asked on

how do i add information into database students (2 or 3 Related- tables)

hi ...good day,
im using vs2010 ultimate, i made a database for students & a simple one nothing fancy (winforms c#), just to track and record abcense and grades and final exam marks... tables are (students with student's ID and other demographics - courses with names and course ID - enrollment table with the keys of coursetbl and studentstbl and another key courseSemester and other fields like midterm exam grade and final grade and abcense times... )
first thing i added service based database (dont know if this is the right thing in the first place) because i want it to be embedded into the form whenever i publish it and to be easily managed or modified (please let me know if i should be using MSSQL server and connect it to my project with connection string and what have you..) please note that courses table i filled it with the data needed because it is known, course name and ID, but did not fill in anything for students table thus nothing in enrollment table...
my main question here:

now that i made these tables, i did not fill them with anything, now, i made the form and want to start adding in data into the enrollmentTbl , but i cannot add because i have to insert data into the students table first. so, do i have to add my student manually to their table then use the form to add data to the enrollment table? ??

or do i have hard code SQL insert statements/commands to insert (first into students table) then right below that command will make another command to insert into the enrollment table???
the latter works fine as a quick fix (unless it is the right thing to do) but does not feel right considering some DB rules or referential integrity rules or something i mean im not sure and i dont really know how to go about it.

on  a side note here, i tried to insert one record was in studentsTBL saved it then  i tried adding records into enrollementTbl (from the DB made within VS2010) with different student ID numbers, and saved fine, im guessing should it not say that i have to have a matching record in the studentsTBL ?

studentsTBL
PK = stdid
fname
lname
city

coursesTBL
PK=courseID
courseName

EnrollmentTBL
PK=semTaken
FK=courseID
FK=stdid
midtermGrade
AbcenseTimes
volunteerWork
FinalExam

i tried making a few Views and looks amazing but i need to know if im doing things right or maybe after adding 100 students i find that i messed the DB up and DB gets sick...

Many thanks in advance.
Microsoft SQL ServerEditors IDEs.NET Programming

Avatar of undefined
Last Comment
ahashash

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Aaron Jabamani

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ahashash

ASKER
Many thanks, it works now, you r right about entering manually, regards
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy