Riddhi Valecha

Riddhi Valecha

  • 443
  • 3.3k
  • 413k

Uniqueness between 3 fields

Feb 11 2016 5:38 PM
Hi all...
 
I need a logic in SQL Server database end -
I have 4 master tables -
1. EmployeeMaster
1 - Abhineet
2 - Neha
3 - Jaya
etc - 55 employees (1,2,3 - auto increment primary key)
--------
2. SubjectMaster 
1 - Java
2 - Project Management
3 - Time Management
4 - Oracle 
etc - 100 subjects(1,2,3,4 - auto increment primary key)
-------------
3. OtherSubjectMasters
1- AJAX
2 -Query String
etc - 90 records (1,2,3... auto increment primary key)
-----------
4. Ouarters -
Q1(April2016-June-2016)
Q2(July2016-September2016)
Q3(October2016-December2016)
Q4(January2017-March2017)
-----------
Now, from front - end, the dropdownlist is binded with SubjectMaster.
Incase, the user wants to insert other subject (not present in SubjectMaster table, then he/she inserts othersubject in OtherSubjectMaster table)
---------
Transaction table -
 ID EmpID SubjectID OtherSubjectIDQuarter
 1 1 (Abhineet)
 1 0 Q3(October2016-December2016)
 2 1 (Abhineet)
 0 2 Q4(January2017-March2017)
     
 
Here, if user enters subject from dropdownlist(subjectmaster table), then "SubjectID" field will have the ID of Subject and OtherSubjectID will have 0.
----
 
Logic that I need -
I want to check that one employee - is allowed to attend one training in one quarter.
Eg - here now, Abhineet will not be able to attend the training of subject id - 1 in Quarter-3 (Q3).
He may attend training of other subjects in this same quarter - Q3.
How do we get uniqueness between - Employee , Subject and Quarter ??
 
Please guide....

Answers (12)