forget to say, i only offer 20 score because I have no time to answer only questions to earn any, i expect to ask 20 questions by the account. I know the question is not very simple since it concerns db designing. it worths some hundred dollars actually. if you need more score, i could register an extra id and offer you 200 score :) i am very appreciate of your suggestion !with best wishessandy
# # Table structure for table 'finance_accounting' #DROP TABLE IF EXISTS `finance_accounting`; CREATE TABLE `finance_accounting` ( `id` int(32) NOT NULL auto_increment, `type` char(1) NOT NULL default '', `user_id` int(32) NOT NULL default '0', `credit_card_name` tinyint(2) NOT NULL default '0', `credit_card_last4digits` tinyint(4) NOT NULL default '0', `valid_until` date NOT NULL default '0000-00-00', `amount` float(10,2) NOT NULL default '0.00', `timestamp` timestamp(14) NOT NULL, PRIMARY KEY (`id`), KEY `key_timestamp` (`timestamp`), KEY `key_type_id` (`type`,`user_id`) ) TYPE=MyISAM;这 样 设 计 是 否 合 理 ? 先 谢 谢 啦 !
#数据库类型要设为InnoDB。 thanks !#现在的mysql并不支持外键。 i awared. :)#建议去了 id, 这的确是一个不必要的字段, 你还为它建立了主索引! 这会很大的影响你的系统速度 this is the most case I could not decide, ya, thanks a lot!I will try this KEY `key_type_id` (`type`,`user_id`) 为主键#,有效期倒是可以做一个索引的 ? currently i have no idea how to handle the valid date. maybe just check whether it is later than current time? with best wishessandy
1,id (unique id) (其 实 可 有 可 无 , 不 过 习 惯 上 每 个 表 我 都 写 这 个 id)
2,type (b or u to present business or user) (区 分 用 户 是 来 自 商 家 还 是 用 户 )
3, userid (business id or user id)???(商 家 和 用 户 的 各 自 唯 一 id, 和 第 二 条 type一 起 确 定 系 统 中 唯 一 的 用 户 )
4, credit_card_name (visa, american express, etc)(信 用 卡 的 类 型 )
5, credit_card_last4digits (信 用 卡 的 最 后 4位 数 )
6, valid_until (信 用 卡 的 有 效 期 )
7, amount (us$) (支 付 的 金 额 )
8,timestamp (时 戳 )月 底 报 表 还 包 含 很 多 用 户 的 信 息 ,为 了 减 少 冗 余 , 我 通 过 2, 3条 查 出 唯 一 用 户 的 姓 名 , 地 址 , 邮 编 , 国 家 等 等 。 我 以 为 要 用 foreign key, 是 不 是 没 必 要 啊 ? 我 决 定 对 2,3做 index 加 速 查 询 , 时 戳 好 象 也 要 做 一 个 index。 说 我 分 得 不 细 , 是 因 为 信 用 卡 类 型 吧 ? 还 有 哪 些 缺 陷 , 请 多 指 教 。 with best wishessandy
# Table structure for table 'finance_accounting'
#DROP TABLE IF EXISTS `finance_accounting`;
CREATE TABLE `finance_accounting` (
`id` int(32) NOT NULL auto_increment,
`type` char(1) NOT NULL default '',
`user_id` int(32) NOT NULL default '0',
`credit_card_name` tinyint(2) NOT NULL default '0',
`credit_card_last4digits` tinyint(4) NOT NULL default '0',
`valid_until` date NOT NULL default '0000-00-00',
`amount` float(10,2) NOT NULL default '0.00',
`timestamp` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
KEY `key_timestamp` (`timestamp`),
KEY `key_type_id` (`type`,`user_id`)
) TYPE=MyISAM;这 样 设 计 是 否 合 理 ? 先 谢 谢 啦 !
另外,现在的mysql并不支持外键。
你还为它建立了主索引!
这会很大的影响你的系统速度
直接使用
`user_id` int(32) NOT NULL default '0', 为主键,
或
KEY `key_type_id` (`type`,`user_id`) 为主键另,有效期倒是可以做一个索引的
thanks !#现在的mysql并不支持外键。
i awared. :)#建议去了 id,
这的确是一个不必要的字段,
你还为它建立了主索引!
这会很大的影响你的系统速度
this is the most case I could not decide, ya, thanks a lot!I will try this KEY `key_type_id` (`type`,`user_id`) 为主键#,有效期倒是可以做一个索引的
? currently i have no idea how to handle the valid date. maybe just check whether it is later than current time? with best wishessandy