I am developing a report on my system to control the productivity of teams, the team table has the following information:
(tblequipe)
| id (pk) | nome | meta |
| 1 | EQ01 | 5 |
| 2 | EQ02 | 7 |
| 3 | EQ03 | 6 |
One problem I encountered was when I viewed the productivity of teams when there was no data, for example, how do I consider team productivity on 01/01 if there is no release (this release is in a table that contains the data gross, that is, several records that will be added giving the total amount executed on a certain day) on that date? So I thought about creating these two tables:
(tblmapa)
| data | id_equipe | meta |
| 01/01 | 1 | 5 |
| 02/01 | 1 | 5 |
. . .
. . .
. . .
| 31/01 | 1 | 5 |
---------------------------------
(tblprodutividade)
| data | id_equipe | executado |
| 01/01 | 1 | 9 |
| 05/01 | 1 | 3 |
| 06/01 | 1 | 5 |
This could retrieve the data with this select:
SELECT
m.data,
m.id_equipe,
m.meta,
isnull(p.executado, 0) executado
FROM
tblmapa m
left join tblprodutividade p on (p.data = m.data and p.id_equipe = m.id_equipe)
My question is regarding tblmapa
and tblprodutividade
, I would like to know if it is more appropriate to create a id column in each of them as identity primary key and set the columns data
and id_equipe
to unique or maybe just create the columns data
and id_equipe
as primary key . >
Additional
I would like a response that takes into account the performance and storage space of the primary key unique or primary key , with columns are of type date and int respectively.
Related question
#