Best way for choosing datatype
What is the best way for choosing a datatype like if I have ID,Name,Mobile,Email,Phone,Address as the database fields.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shweta LodhaRank #31 · 39.8K reputationPosted Dec 29, 2014, 8:31 AM EST
Wim SturkenboomRank #2,527 · 554 reputationPosted Dec 29, 2014, 9:50 AM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 29, 2014, 6:12 PM EST
Hi Faiza Saher,
Actually it depends on your requirement which type of data you want to store in that field. First decide that and find the data type that is the best matched for your requirement.
Riddhi ValechaRank #794 · 2.9K reputationPosted Dec 29, 2014, 9:09 PM EST
I would suggest,
ID - numeric(25,0) not null PK auto increment.
Name - varchar(60) not null
Mobile - numeric(18,0) allow nulls (in front-end, check that value is 10-digit mobile)
Email - varchar(100) allow null (eg - [email protected])
Phone - varchar(100) allow null (Eg- 020-2765432)
Address - varchar(max) (Eg- Street-21, New York).
----------
ID will be unique primary key - auto increment.
---------
See if this helps you out.
Rahul SinghRank #1,323 · 1.3K reputationPosted Dec 29, 2014, 11:11 PM EST
It all depends on the data you are going to store, as per the naming convention, I would suggest the following types:-
ID - INT
Name - NVARCHAR
Mobile - NVARCHAR
Email - NVARCHAR
Phone - INT \ NVARCHAR (again depends on data you are going to store)
Address - NVARCHAR