开发者

Licensing issue

I have a .NET application that is storing information in an sql server database.

I wanna add licensing to my app to only allow a certain number of items in the DB depending on the license. So say, for example, that i have an "items" table and the license is for 5000 items.

The problem i'm facing is that i can't rely on my app not inserting the item if the table row count is > 5000, because the user can insert items directly into the DB since the server is provided by the customer so he wi开发者_如何学编程ll have full unrestricted access to the DB. (i can't use any sql server-side solutions as well due to this particular issue)

Also, if i add a field to the table that i fill with the item info hashed with a password then the user can no longer add items manually but then i'll have to run through the whole table and check whether each item is licensed and count licensed items before determining whether to add each new item or not. This is not practical since i receive hundreds of items per minute so it will greatly affect performance.

Does anyone have any idea on how to achieve this?


Your best bet might be an INSTEAD OF trigger on the Items table to reject inserts beyond your limit.


You could turn the restriction upside down and limit your queries to 5000 results. This can be easily done with the TOP clause.

This way it doesn't matter how many rows the user shoves into the database, your program will only work with the ones it's licenced to.


I also recommend a simple trigger (which you can base on a configuration table if you want).

I'd like to know a little more about the overall business requirements, since it seems like the table would fill up in under an hour if you are receiving hundreds of rows a minute.


I would decouple the license validation from your DL all together. Instead have your app run a its validation script at some point and then take the required (disabling/warnig) action if validation fails.

Something like this should return very quickly:

SELECT [TableName] = so.name, [RowCount] = MAX(si.rows) FROM sysobjects so, sysindexes si WHERE so.xtype = 'U' AND si.id = OBJECT_ID(so.name) GROUP BY so.name ORDER BY 2 DESC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜