I have two database tables, Team (ID, NAME, CITY, BOSS, TOTALPLAYER
) and
Player (ID, NAME, TEAMID, AGE
), the relationship between the two tables is one to many, one team can have many players.
I want to know is there a way to define a TOTALPLAYER
column in the Team
table as computed?
For example, if there are 10 players' TEAMID
is 1, then the row in Team
table which ID
is 1 has the TOTALPLAYER
column with a value of 10. If I add a player, the TOTALPLAYER
column's value goes up to 11, I needn't to explicitly assign value to it, let it generated by the database. Anyone know how to realize it?
Thx in advance.
BTW, the database is SQL Server 2008 R2
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…