Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data Types used in SQLite

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?)

like image 358
user3127791 Avatar asked Dec 31 '13 02:12

user3127791


2 Answers

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. :)

like image 92
user2339071 Avatar answered Oct 13 '22 06:10

user2339071


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.

like image 2
Chintan Soni Avatar answered Oct 13 '22 06:10

Chintan Soni