last day (15 days later) » 

1:34 PM
0
A: the number of columns (1) does not match the number of columns in the referenced key (2)

BernardoLimaReferences TB_EMPLOYEE on which field? You must specify it. ALTER TABLE TB_ATTENDANCE ADD CONSTRAINT FK_TB_EMPLOYEE_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES TB_EMPLOYEE(EMP_ID);

 
It's still the same.. there is no unique or primary key constraint on table '"ORLY"."TB_EMPLOYEE"' that matches the number and types of the columns in the foreign key. and I'm sure that the FK has the same type with its reference.
 
Edited my answer, try now with the command 'ADD CONSTRAINT'
 
Syntax error: Encountered "ADD" at line 1, column 64. Nothing happens
 
Sorry, I mistyped two 'ADD's, please try now.
 
same error again: there is no unique or primary key constraint on table '"ORLY"."TB_EMPLOYEE"' that matches the number and types of the columns in the foreign key. I don't know why.
I think It's because that the EMP_ID in the TB_EMPLOYEE is auto increment. Don't you think sir?
 
1:34 PM
Are both fields extactly the same type (int)?
Hey, I'm leaving home in a few minutes
I'm going to travel, sorry
But
Check if both fields are the same type, and post the screenshots from the tables structures
 
I think It's because that the EMP_ID in the TB_EMPLOYEE is auto increment.
and they both the same int
 
But isn't EMP_ID it's PK?
 
yes
 
If yes, then PKs are auto incremental
The FK shouldn't be, if it's
 
I will try then
 
1:37 PM
Is it auto incremental on TB_ATTENDANCE?
 
nope
 
Did you check both fields type?
Are they both exactly the same?
 
yes they both type (int)
they have same properties but one isn't auto increment
 
The FK shouldn't be ai
Would you mind sending some screenshot from tables structurew
*structure
 
ok.. wait
 
1:39 PM
I guess the problem is there
 
but I tried to put an FK in other table one is auto increment while the other is not. but it works.
 
But if EMP_ID is your TB_EMPLOYEE PK, it should be auto incremental
Every time you add a row on TB_EMPLOYEE, it would auto increment it's id automatically for you
 
yes it's auto increment.. but in TB_ATTENDANCE the EMP_ID isn't.
 
If you remove that you will have to manage it manually which is not a good practice and could be hard work to implement a solution to manage IDs
Actually not really hard but really not a good practice
PKs must be auto incremental, FKs don't, because they are going only to point to the PKs
 
ok sir.. I will find the solution with my own.. thanks for your help. :)
 
1:46 PM
Well, I gotta leave ,but if
*but if you send me the tables structure I help you later.
See you
 
wait
what do you mean by table structure?
is it ERD?
 
 
2 hours later…
3:44 PM
Hello are you still there
 
4:09 PM
yup
I already solve the problem. lol
 
4:21 PM
What was the problem?
Your FK was setted as PK too
 
4:39 PM
I don't have to make the EMP_ID to be FK because It's data is not unique. In other words, I don't have to make it a primary key.
 
You were using a FK as PK right
 
yes
 

last day (15 days later) »