I'm confused what to declare as datatype in SQLite for the following: 1.email 2.phone number 3.password(Some articles I find that they use String instead of int for phone number and password , why is it so?)
There are fundamentally 5 types of datatypes in SQLite:
1.) NULL 2.) BLOB 3.) INTEGER 4.) REAL 5.) TEXT
You can read them up on the following page SQLite Datatypes.
As for your question :
1.) Since Email
can contain alphanumeric and special characters, this field has to be declared as TEXT
.
2.)For a phone number , you have to decide as to how to store the numbers. For e.g. one of the guys would want his phone number to be stored as
4567890
While some other guy would want the same number to be stored as
456-7890
In the first case
, the datatype would be INTEGER
while in the second case
it would TEXT
as the second case consists of special character.
3.) For password
, use TEXT
as it can have any character. Be sure to encrypt it though.
Hope it helps. :)
The reason behind using string is that, Sqlite was made much flexible and dynamic.
Check this link: http://www.sqlite.org/datatype3.html
First two paragraphs answers all of your questions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With