Block list table (IP, Mac, email, name, username)
I am creating block lists to block user actions based on IP address, MAC address, Email address, Name (first/last name), Trademark names and Usernames. So should each of these be a separate lookup table or can there be one blocked_list table with all开发者_运维技巧 these in? Each is individual independent of the other.
The list will be used in few places ->
User signup - block account signup based on IP, MAC, email & any disallowed First/last name Username creation - block username creation based on restricted usernames Profile details - block profile email being added based on disallowed emails Public pages - block people from naming pages based on a restricted list of trademarked names.Also, is it better to keep this in the DB or a text file? Except trademark names everything else will be in English. For trademarks I may use region specific blocking so need multi-lang support.
I'd make each their own table.
how would combining them make your queries run any faster? it wouldn't.
It isn't like you won't know what you have, if you have a MAC address check in the block MAC address table for it, it would be your primary key which would be defined to the exact proper length and type for a MAC address.
What about having 1 table with all the values in and have a column - block_type. You will need a lookup table for block_type where 1=IP. 2 =MAC,... This was you can manage this with only 2 tables. But I'll let someone more professional answer this as I am new myself to databases.
You can put all the entries in a single table. Check out the Entity-Attribute-Value approach or use a schemaless NoSQL datastore.
http://en.wikipedia.org/wiki/Entity-attribute-value_model
If you're processing the 'blocking' in the middle tier, you can just dump the lists as serialized objects (e.g. JSON) into the table.
精彩评论