建模建模,一开始就建模型吧

dwangel 2006-12-20
借用rails4day得model如何?

CREATE TABLE `categories` (
`id` int unsigned NOT NULL auto_increment,
`category` varchar(20) NOT NULL default '',
`created_on` timestamp(14) NOT NULL,
`updated_on` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `category_key` (`category`)
)

create table items
(
id int auto_increment,
done tinyint,
priority tinyint,
description varcahr(250),
due_date datetime,
category_id int,
note_id int,
private tinyint
)
* done - 1 意味着这件事情已经完成
* priority – 1 (高) to 5 (低)
* description – 简述这个任务
* due_date – stating when it is to be done by
* category_id – 外键指向category的一个分类
* note_id – 外键指向note表.
* private – 1标识这个任务是私有的.

CREATE TABLE notes (
id int NOT NULL auto_increment,
more_notes text NOT NULL,
created_on timestamp(14) NOT NULL,
updated_on timestamp(14) NOT NULL,
PRIMARY KEY (id)
)
抛出异常的爱 2006-12-20
用uml或类图吧
数据库最后再加?
dwangel 2006-12-20
偶是偷懒。 在rails4day里有图的。
eastviking 2006-12-22
数据库结构参考project比较好,一个完整的以项目管理并且要分层的todo数据表至少要有以下信息。
    t.column "created_at", :datetime, :null => false  #创建时间
    t.column "updated_at", :datetime, :null => false  #更新时间
    t.column "position", :integer, :default => 0, :null => false  #位置,用来排序
    t.column "parent_id", :integer, :default => 0, :null => false #要实现层管理,必须有parent_id
    t.column "textfield_id", :integer, :default => 0, :null => false  #详细内容
    t.column "project_id", :integer #所属项目
    t.column "todo_start_date", :datetime  #to_do开始日期
    t.column "todo_finish_date", :datetime #结束日期
    t.column "todo_outline_level", :integer, :default => 0, :null => false  #缩进层次(树的深度)