Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have created a database for students' attendance. I am facing an issue: if students scan their card twice there are two entries shown on the same day. I want one entry per day, and if someone tries twice then one entry should be deleted.

For this I have a table containing RFID numbers which are allocated to each student (this number is unique as well) and a auto current date & time when entry posted.

Now please suggest me how to stop the 2nd entry by coding as entry is done from a FORM which is directly connected with table. Thanks in advance.

share|improve this question

1 Answer

up vote 1 down vote accepted

You should have one table with student information and one table in which you store the combination of the date and the primary key (your RFID i presume). Then you should define a Primary key on the new table, that consist of the date + RFID. Since this is your primary key this has to be unique, and scanning a card twice won't allow it to be entered twice.

share|improve this answer
Dear Glenn i have done as per your statement given above. now system restrict me when doing the scanning twice. now what if i show the Error message on duplication ??? is this possible ??? – Muhammad Usman RAza Jun 9 at 10:57
The primary key constraint ensures uniqueness of the combined fields that form the primary key. Because of that database prevents you from adding another record with the same RFID/date combination. You need to handle the error in your application. – Ansgar Wiechers Jun 10 at 7:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.