0
In a system there are plots registrations . The users can classificar
as plots for familyDeParcela each of which user has its own familyDeParcela.
As plots are common to all.
I have 4 tables:
User that has cod_usuario
PK
Parcel that has cod_parcela
PK
Familiadeparcelas that has cod_usuario
FK and cod_familia
PK
Parcel that has cod_familia
FK , cod_parcela
FK , and a PK composed of cod_familia
and cod_parcela
Example of use :
We have 5 plots registered
Horas extras além da 6a,
Horas extras além da 8a,
danos morais,
danos materiais,
periculosidade.
User 1 registers the families HORAS EXTRAS
, DANOS
and OUTROS
that will belong only to him and then can classify
Horas extras além da 6a --> HORAS EXTRAS
Horas extras além da 8a --> HORAS EXTRAS
danos morais ---> DANOS
danos materiais ---> DANOS
periculosidade ----> OUTROS
And user 2 registers the families SALARIAL
and INDENIZATÓRIA
that will belong only to him and then can classify
Horas extras além da 6a --> SALARIAL
Horas extras além da 8a --> SALARIAL
danos morais ---> INDENIZATÓRIA
danos materiais ---> INDENIZATÓRIA
periculosidade ----> NULL ( DEIXAR SEM CLASSIFICAR )
When a user is using accurate listar
all the plots with your Familiadeparcela and if it has not been classified , return only the data from installment, but only that user !
If I do
select *
from Parcela p
left outer join Parcela_FamiliaDeParcelas pf ON pf.cod_parcela = p.cod_parcela
left outer join FamiliaDeParcelas f on f.cod_familia = pf.cod_familia and f.cod_usuario = @codusuario
With this query for each classification user makes it returns 1 extra occurrence for each classification of the same portion as another user did ( but with null
in the data of family )
Add at the end a where f.cod_usuario = @codusuario
he returns only the plots of user , but not the plots unclassified
What should I do ?
The diagram you made is correct Eduardo, but a portion does not belong to a user and so I can not put in parcel a FK_USUARIO . Nor can I put Fk_familia in the plot since it does not belong to a user and each user can make their own rating. If I did that I would have to re-register all installments for all users . ex installation1 , usuario1 ,familia1 / installation1 , usuario2,familia2
– John Diego
I will try to clarify here , let’s consider that Parcel = Product , Familiadeparcela = Category in a system that all users can sell Rice , chocolate and soda . a user can create a food category and classify Rice, Chocolate and Soda as food. a second user creates 3 categories food, sweet and drink , and classifies rice as food , chocolate as sweet and soda as drink .
– John Diego
Eduardo, I managed to solve using right Join ! Thank you so much for the help, I was extremely happy to receive your reply with the work of making the diagram and everything. Soon I will delete this question because I think it does not help many people and really confused . But not before thanking . Brigadesso !!
– John Diego
Kkkkk. From your first comment what I was going to actually wouldn’t work. But I’m glad you did. We’re here for that, to try to help. Be at peace.
– Eduardo Mendes
It was the first time I had to wear right Join in my life! I had to start the query from Familiadeparcela to then do the Join in the union table using Familiadeparcela.id and not Parcel.id and how I had to list all the plots right Join Parcel at the end , done this worked right ! the//
– John Diego