473,241 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Violation of primay key

Hi I am a first time user of sql server, and of late I am trying to build a database using sql server and I am starting to panic.

This is what I am trying to do: I am creating a db to register incoming students into a course.

1. I have two tables. Table A has all the fields for the student personal information in which I have Record # as the primary key. Table B has fields for the incoming student Educational Background (high school subject past) which has a Record # as the primary key.

2. I created a form using Table A and a subform using Table B which is linked via the Record #.

3. I am able to enter student personal information and one educational background information for a student, for example the school they attended, the year, subject pass and the grade.

However a student can have grades for more than one subject and there is where my problem is. The subform is continuous form since one student can have many subject past. When I enter information for a second subject for the same student in the subform I get " violation of primary key constraint 'PK_Education' Can not insert duplicate key in object 'Education' ".

How can I solve this problem?

What do I need to do or undo?

As I said before I am new to sql server and any help will be nice.

Thanks very very much.
Feb 18 '07 #1
1 1501
168 Expert 100+
You didn't partitioned your data correctly. As I understood you have:
1. Students
2. Subjects
3. Student grades on specific subjects.

Than you have to create three tables:
1. Student (StudentID, Name, ...) - will contain information about all students
2. Subjects (SubjectID, Name, ...) - will contain information about all subjects
3. Education (StudentID, SubjectID, Grade, DatePassed, ...) - will contain information about subjects passed by students.

This is a simple many-to-many relationship. It means that several students can pass a single subject, as well as one student can pass several subjects. This logic is accomplished using third table that handles relationship between Students and Subjects.
Feb 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling...
by: Steven Reddie | last post by:
In article <slrnbnj19j.av.juergen@monocerus.manannan.org>, Juergen Heinzl wrote: >In article <f93791bd.0309282133.650da850@posting.google.com>, Steven Reddie wrote: >> I understand that access...
by: J Smith | last post by:
After doing some googling through the lists and such, I wasn't able to arrive at a solution for a problem I've run into recently. I've seen mention of similar symptoms, but my case seems different....
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
by: Microsoft News | last post by:
I'm getting the following error when I shut down my C# .NET v1.1 application: 0xC0000005: Access violation reading location 0x73bc0000 This error didn't occur until I added a...
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
by: Vayse | last post by:
In my save code, most of items save fine. But sometimes I get a concurrency violation message. "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." It happens on the...
by: Kai-Uwe Bux | last post by:
Please consider: struct X { int x; X ( int i = 0 ) : x ( i ) {}
by: Martin | last post by:
I have an intranet-only site running in Windows XPPro, IIS 5.1, PHP 5.2.5. I have not used or changed this site for several months - the last time I worked with it, all was well. When I tried it...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.