First Name
Phone Number
Email
Address
For the above values, what would be the
Type
Length
Collation
Index
And why, as well as - is there a guide somewhere that I can use to determine these answers for myself? Thanks!
First Name
Phone Number
Email
Address
For the above values, what would be the
Type
Length
Collation
Index
And why, as well as - is there a guide somewhere that I can use to determine these answers for myself? Thanks!
This is somewhat dependent on database platform and the underlying requirements. These are typically all nvarchar or varchar types. You are the best at knowing the appropriate length given your requirements. For collation you can usually use the default but again it depends on your situation. I suggest reading up on indexes to address what indexes you need.
I agree with the others, you should do some reading on beginning SQL. I also suggest just implementing something and you can always change it after the fact. You'll learn a lot from just trying it and running into issues that you will then need to solve.
Good luck!
For names, should I use varchar / text / tinytext / blob? What is the typical name length?
varchar
type should doAs for length: pick a reasonable value, but don't use varchar(67)
, varchar(91)
, varchar(55)
and so forth - try to settle on a few "default" lengths, like varchar(20)
(for things like a phone number or a zip code), varchar(50)
for a first name, and maybe varchar(100)
for a last name / city name etc. Try to pick a few lengths, and use those throughout
Use such knowledge to "tune" your string lengths. I would advise against just using blob type / TEXT
/ VARCHAR(MAX)
for everything - those types are intended for really long text - use them sparingly, they're often accompanied by less than ideal access mechanisms and thus performance drawbacks.
Indexes: in general, don't over-index your tables - most often devs tend to have too many indexes on their tables, not fully understanding if and how those will be used (or not used). Every single index causes maintenance overhead when inserting, updating and deleting data - indexes aren't free, use them only if you really know what you're doing and see an overall performance benefit (of the whole system) when adding one.