> > I think this is common DB design on many websites that have registered > > user IDs. > > > > Is it? Name one! Sounds like crappy design to me. >
It might sound crappy design to you, but for websites that allow users to do something while they are registered OR unregistered, will choose to have this for query speed. (Registered user goes in as "testuser" while an unregistered one goes as his IP address--some websites also use cookies but they're less reliable.) We can make this very relationally sound and whatnot, but having one field to go to, whether you are registered or not, makes it much simpler. Most websites have to allow for dots in their user ID these days as people prefer to have their email address as user ID. Which means that the dot checking of an IP address may not work to distinguish IP addresses (unregistered user) from registered user IDs. In this scenario, for query speed, again, if there is a column that tells us whether this user is registered or not it helps a great deal. The INET match condition is not good enough for speed for most modern websites with any sizeable traffic. I even wrote a function that converts IP to INET integer and vice versa, but no great boost in query speed that could compare to an indexed query on user_id and user_reg. Welcome your thoughts on how you would do it. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general