Data Types Used in SQLite

I am confused by what to declare as a data type in SQLite for the following: 1.email 2.phone number 3.password (In some articles I find that they use String instead of int for phone number and password, why is this so?)

+7
android sqlite android-sqlite
source share
3 answers

There are basically 5 types of data types in SQLite:

1.) NULL 2.) BLOB 3.) INTEGER 4.) REAL 5.) TEXT

You can read them on the next page SQLite Data Types .

Regarding your question :

1.) Since Email can contain alphanumeric and special characters, this field must be declared as TEXT .

2.) For the phone number, you must decide how to store the numbers. E.g. one of the guys wants his phone number saved as

4567890

For now, some other guy would like the same number to be saved as

456-7890

In the first case , datatype would be INTEGER , and in the second case it will be TEXT , since the second case consists of a special character.

3.) For password use TEXT since it can have any character. Be sure to encrypt it, though.

Hope this helps. :)

+6
source share

The reason for using the string is because Sqlite has been made very flexible and dynamic.

Check out this link: http://www.sqlite.org/datatype3.html

The first two paragraphs answer all your questions.

+2
source share

Use String for all three.

String allows you to use the full range of characters, including lowercase, uppercase, numbers, and special characters. Each of the examples you provided (email address, phone number and password) will use elements from the full character set. (email '@', phone '-' and '()', and passwords are more effective the larger the character set selected from.)

Strings can also be parsed using regular expressions to test them and match the database. For example, you can select a consistent format for the telephone numbers “++ 64 4 12345678” and use RE to achieve this state before storing it in the database. Equally, you can use REs to remove all extra characters and save the phone number as an int.

Passwords using only int, have a character base of 10 characters, the full character set has (26 + 26 + 10 + 33) = 95 characters. If your password is 8 characters long, then there are 10 ^ 8 or 100,000,000 combinations (trivial for brute force) or 95 ^ 8, which is much more than brute force more difficult.

0
source share

All Articles