0
I am aware of a problem in the use of foreign key. I cannot find the logic for a system:
The problem: the user gives a note for each question, each one being a table field, and at the end the average is calculated and inserted into the database. But this note, as well as the average is cumulative, that is, the second user will give his notes and will be added with the evaluation of user 1, divided and thus will be generated the average. I’m not getting to understand how I can recover the notes and the average given by user 1. Can anyone help me just with logic, please.
Change your question by showing how your database is
– Italo Rodrigo
I added the image
– Isac Moura
Tell me something: this table you posted already has one
idUser
andmedia
. In case, it wouldn’t just be making aselect media from tabela where idUser = 1
?– Italo Rodrigo
Rephrase your question, I will answer because I think I understand but as it was assembled it is not clear how it works. remember you are involved in this context other users not!
– Rafael Salomão
I don’t know if I’m the one who’s complicating things or really just that. The user id is to be the foreign key of the user id of a table called users. If I make the command above selecting the average, it will return the average given by that user and not the cumulative average, this?
– Isac Moura
I’ll edit here
– Isac Moura
am answering ....
– Rafael Salomão