Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   SQL (MS Access) (https://thetfp.com/tfp/tilted-technology/44220-sql-ms-access.html)

Artsemis 02-03-2004 04:05 PM

SQL (MS Access)
 
Working on a class assignment and I have just a couple questions here...

1) Is there any way to create multiple tuples and add them to a table using the same Query? If I do the add command and end it with a semi-colon, I get a message about text being after the end of the query; if I dont use a semicolon, it says it expects one after the first "add" statement.


2) Okay, the book gives many examples about relationships. Lets use this for example... say we have Students( sid, age, gpa ), and Enrolled( sid, courseID, grade ).
Now, here's the problem... the book has the following as Primary keys:
Students - sid
Enrolled - sid, courseID

And the following Foreign Key:
Enrolled - sid (References Students)

Now, this causes a problem in my eyes. As it appears, it seems a single student is unable to be "enrolled" in more than one course. It seems to me that when you add a student for the second time to the table to be Enrolled for a course (different courseID) it violates the Primary Key (sid) because that students sid hasn't changed.

For now, I deleted my two Primary Key's in "Enrolled" and just left the Foreign Key to keep the two tables in sync... am I missing something or is the book not compatible with Access's SQL?


Thanks~!

cheerios 02-03-2004 04:48 PM

ok can't help you on the first one, but the second one I can. :) here's the deal. a PK has to be unique for each entry, right? so with the primary key of Students being sid and the PK of Enrolled being BOTH sid and courseID, then both sid & courseID have to match to cause a key constraint.

so you could have
sid_______CourseID
9887--------1235
9887--------1236
both in enrolled and not cause an error. theo only time you'd have problems is if the same student tried to enrol in the same course multiple times. am i making sense?

Artsemis 02-03-2004 04:53 PM

Ahh, thanks! I thought when they was together (sid, courseID) it meant one or the other, not both =)


Anyone on the first question? =)

gigawatz 02-07-2004 12:17 AM

Unfortunately, I cannot provide any good news. Everytime I attempt to create multiple SQL statements into a single SQL instance in Access it gets pissed.

I have not thoroughly researched doing this, cause I don't rely on access to do my db work, however, through experience, I do not think that is possible. It is perfectly valid in any other database application that I've ever run into.

I wish you luck.


All times are GMT -8. The time now is 08:37 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73