Database Reference
In-Depth Information
Consider an example of the User table where we have various attributes, such as first
name, last name, e-mail, address, username, password, and so on. We can store all these
items together in a table. But we know that username and password are two such import-
ant fields that would be used more frequently compared to first name, last name, address,
and so on. So, it's efficient to store first name, last name kind of attributes in one table and
username and password in another table. So if there are any issues with one of the tables,
it would not harm the other table.
Inefficient approach
The following table shows how a user table would look if we keep everything in that table
itself.
Table - User
{"uid":"111","firstname":"ABC", "lastname":"XYZ", "address":"St. Paul Street, 11, Oxford",
"username":"xyz123", "password":"xyz@34211", "email":"xyz@pqr.com"}
{"uid":"112", "firstname":"DEF", "lastname":"XYZ", "address":"St. Paul Street, 12, Oxford",
"username":"def123", "password":def@34211", "email":"def@pqr.com"}
Better and efficient approach
As said earlier, if we segregate the credentials from user table, this is how it would look
like.
Table - User
{"uid":"111", "firstname":"ABC", "lastname":"XYZ", "address":"St. Paul Street, 11, Oxford",
"email":"xyz@pqr.com"}
{"uid":"112", "firstname":"DEF", "lastname":"XYZ", "address":"St. Paul Street, 12, Oxford",
"email":"def@pqr.com"}
Table - UserCreds
{"uid":"111", "username":"def123", "password":def@34211"}
{"uid":"112", "username":"def123", "password":def@34211"}
Search WWH ::




Custom Search