i am using a simple database design and i think the best database example is e-commerce, because it does have a lot of problems, and its familiar to cms.
USERS TABLE
UID |int | PK NN UN AI
username |varchar(45) | UQ INDEX
password |varchar(100) | 100 varchar for $6$rounds=5000$ crypt php sha512
name |varchar(100) | 45 for first name 45 for last 10 for spaces
gender |bit | UN ,0 for women 1 for men, lol.
phone |varchar(30) | see [2]
email |varchar(255) | see RFC 5322 [1]
verified |tinyint | UN INDEX
timezone |tinyint | -128 to 127 just engough for +7 -7 or -11 +11 UTC
timeregister |int | 31052010112030 for 31-05-2010 11:20:30
timeactive |int | 01062010110020 for 1-06-2010 11:00:20
COMPANY TABLE
CID |int | PK NN UN AI
name |varchar(45) |
address |varchar(100) | not quite sure about 100.
email |varchar(255) | see users.email, this is for the offcial email
phone |varchar(30) | see users.phone
link |varchar(255) | for www.website.com/companylink 255 is good.
imagelogo |varchar(255) | for the retrieving image logo & storing
imagelogosmall |varchar(255) | not quite good nameing huh? let see the comments
yahoo |varchar(100) | dont know
linkin |varchar(100) | dont know
twitter |varchar(100) | twitter have 100 max username? is that true?
description |TEXT | or varchar[30000] for company descriptions
shoutout |varchar(140) | status that companies can have.
verified |tinyint | UN INDEX
PRODUCT TABLE
PID |int | PK NN UN AI
CID |int | from who?santa? FK: company.cid cascade delete
name |varchar(100) | longest productname maybe hahaha.
description |TEXT | still confused useing varchar[30000]
imagelarge |varchar(255) | for the retrieving product image & storing
imagesmall |varchar(255) | for the retrieving small product image & storing
tag |varchar(45) | for tagging like stackoverflow ( index )
price |decimal(11,2) | thats in Zimbabwe dollar.
- see http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses
- see http://stackoverflow.com/questions/723587/whats-the-longest-possible-worldwide-phone-number-i-should-consider-in-sql-varch
why innodb specific ? please see quote http://stackoverflow.com/questions/3286738/how-to-choose-optimized-datatypes-for-columns-innodb-specific
its getting of the topic so i have to create another question and it people doent understand what im trying to say, or maybe i cant explain what i want there . this time its + database design.
so again please copy the example above and put your changes + comments just like the example. give an advice about it.
Remember for INNODB mysql. read the quote on above link. thanks.