sql server - Counting the number of occurances of something in the database -
For my website, I want to do something that works a bit like a tag on the stack overflow - so some The field will display an auto-complete, and automatically complete number of times that other users have selected each suggested value. I think I would have such a database structure:
Article Article ID Content Tag Ed Tag Tag ID Tag Name Conditions To get this idea Relationships represent the number of times that each tag ID is referenced from the article table. What is the best way to implement it? I can add / subtract from the occurances column on each stored procedures updating the article table, but I miss one, and anyway, there are some problems This occurs when a user removes a tag from some (as it is easy to add 1 to the field for the newly added tag, but it is hard to decide which tag is being changed. ) About SQL Server It is not understandable that there is another strong way to calculate such incidents, that the database system will be handled by itself? It would be fine if the data was cached in a day or time.
You can use this query to get the number of incidents occurring by the tag: Tag tags on tags as events occurring from SELECT Tags.TagId, COUNT (Articles.TagId) articles. Tag by TIGId Group.
It can be used in a visual or stored procedure, and you can set as often as needed to set your website's cache.
Comments
Post a Comment