我正在使用简单的数据库设计,我认为最好的数据库示例是电子商务,因为它确实有很多问题,并且它对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.
- 看到Using a regular expression to validate an email address
- 看到What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone
为什么InnoDB的具体点吗? 请参阅报价How to choose optimized datatypes for columns [innodb specific]?
其获得的话题,所以我必须创建另一个问题,人们不知道什么即时通讯试图说,或者我不能解释我想在那里。这次它的数据库设计。
请再次请
复制上面的示例,并将您的更改+注释与示例
一样。给它一个建议。
记住INNODB mysql。阅读上面链接的报价。谢谢。
你究竟在问什么?你可以说得更详细点吗?你想要解决什么确切的问题?另外,标题中不需要括号内的东西,比如“[innodb]”,这就是标签的用途。 – Charles 2010-07-20 17:44:54
是我的数据库设计吗?我只是想知道人们如何使用这种数据库方案。以及关于innodb的东西,谢谢,它看起来是一个矫枉过正,好在innodb一些像CHAR是更快然后varchar,即时通讯不擅长的事情,所以这里我问。 – 2010-07-20 18:04:42