473,473 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Violation of primay key

1 New Member
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 1507
almaz
168 Recognized Expert New Member
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

15
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...
0
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...
6
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....
6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
0
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...
2
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...
5
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...
7
by: Kai-Uwe Bux | last post by:
Please consider: struct X { int x; X ( int i = 0 ) : x ( i ) {}
39
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.