随笔-295  评论-26  文章-1  trackbacks-0
/**********************
 * 用户-产品-订单模块
 **********************/

/*
    表名称: CUSTOMER(客户信息表)
    ID       (客户编号)
    NAME     (姓名)
    LOGINID  (登陆ID)
    PASSWD   (密码)
    EMAIL    (EMAIL)
    ADDRESS  (地址)
    STATUS   (状态)
*/
create table customer (
    id int not null identity,
    name varchar(80) not null,
    loginid varchar(20) not null,
    passwd varchar(255) not null,
    email varchar(80) null,
    address varchar(80) null,
    status varchar(20)  null,
    constraint pk_customer primary key (id)
);

/*
	表名称: CATEGORY(产品类别表)
	ID    (类别编码)
	NAME  (类别名)
	DESCN (描述)
	Primary Key: PK_CATEGORY PRIMARY KEY(ID)
*/
create table category (
	id int not null identity,
	name varchar(80) not null,
	descn varchar(255) null,
	constraint pk_category primary key (id)
);

/*
	表名称: PRODUCT(产品表)
	ID             (产品编码)
	CATEGORY_ID    (类别ID)
        NAME           (产品名称)
	DESCN          (描述)
	INVENTORY      (存货)
	UNITPRICE      (单价)
	STATUS         (状态)
	ATTR1          (自定义属性1)
	ATTR2          (自定义属性2)
	ATTR3          (自定义属性3)
	ATTR4          (自定义属性4)
	TYPE           (类型)
        CREATETIME     (创建的日期)
        CREATE_USER_ID (创建的操作员)
        MODIFYTIME     (最后一次修改的日期)
        MODIFY_USER_ID (最后一次修改的操作员)
	*/
create table product (
    id int not null identity,
    category_id int not null,
    name varchar(80) not null,
    descn varchar(255) null,
    inventory int null,
    unitprice decimal(10,2) null,
    status varchar(20) null,
    attr1 varchar(255) null,
    attr2 varchar(255) null,
    attr3 varchar(255) null,
    attr4 varchar(255) null,
    type varchar(20) default 'product',
    createtime date null,
    create_user_id int null,
    modifytime date null,
    modify_user_id int null,
    constraint pk_product primary key (id),
    constraint fk_product_1 foreign key (category_id)
    references category (id),
    constraint fk_product_2 foreign key (create_user_id)
    references users (id),
    constraint fk_product_3 foreign key (modify_user_id)
    references users (id)
);

/*
	表名称: ORDERS(订单信息表)
	ID             (订单编码)
	CUSTOMER_ID    (用户编码)
	ORDERDATE      (下订日期)
	TOTALPRICE     (总费用)
	ORIGINALPRICE   (原价格)
	APPLYRULES     (所使用的促销规则)
	REGION         (送货地区)
	SHIPADDR       (发货地址)
	SHIPDATE       (发货日期)
	STATUS         (订单状态)
*/
create table orders (
      id int not null identity,
      customer_id int not null,
      orderdate date not null,
      totalprice decimal(10,2) not null,
      originalprice decimal(10,2),
      applyRules varchar(255) ,
      region varchar(255),
      shipaddr varchar(80) ,
      shipdate date ,
      status varchar(2) default '1',
      constraint pk_orders primary key (id),
      constraint FK_ORDERS_1 foreign key (CUSTOMER_ID) REFERENCES CUSTOMER(ID)

);

/*
	表名称: ORDER_ITEM(订单货物表)
	ORDER_ID       (订单编码)
	LINENUM        (订单行号)
	PRODUCT_ID     (产品编码)
	QUANTITY       (数量)
	UNITPRICE      (单价)
*/
create table order_item (
      order_id int not null,
      linenum int not null,
      product_id int not null,
      quantity int not null,
      unitprice decimal(10,2) not null,
      constraint pk_orderitem primary key (order_id, linenum),
      constraint FK_ITEM_1 foreign key (ORDER_ID) REFERENCES orders(ID),
      constraint FK_ITEM_2 foreign key (PRODUCT_ID) REFERENCES PRODUCT(ID)
);

/****************************
 * 管理员及安全模块
 ****************************/

/*
	表名称: log4j_log(日志信息)
	ID             (序号)
	LOGINID        (登陆ID)
	PRIORITY       (级别)
	LOGDATE        (时间)
	CLASS          (类名)
	METHOD         (方法名)
	MSG            (信息)
*/
create table log4j_log(
      id int not null identity,
      loginid varchar(20) not null,
      priority varchar(10) not null,
      logdate varchar(21) not null,
      class   varchar(255) not null,
      method varchar(100) null,
      msg varchar(255) null,
      constraint pk_log4j_msg primary key (id)
);


/*
  表名称:change_history(领域对象修改记录)
*/
create table change_history(
    id int not null identity,
    entitytype varchar(20) not null,
    entityid   int not null,
    changeColumns varchar(255) null,
    constraint pk_product primary key (id)
);
/*
	表名称: users(用户)
	loginid 登陆ID
	passwd 密码
	name   用户名
	email  邮箱
	region 管理地区
	status 状态
	descn  用户描述
*/
create table users(
      id int not null identity,
      loginid varchar(20) not null,
      passwd varchar(255) not null,
      name varchar(80) not null,
      email varchar(255),
      region varchar(255),
      status VARCHAR(2) default 1,
      descn varchar(255) null,
      constraint pk_users primary key (id)
);

/*
	表名称: roles(角色)
	name 角色名称
	descn 角色描述
*/
create table roles(
      id int not null identity,
      name varchar(80) not null,
      descn varchar(255) null,
      constraint pk_roles primary key (id)
);

/*
  表名称:  user_role(用户角色表)
  user_id 用户ID
  role_id 角色ID
*/
create table user_role
(
  user_id int not null,
  role_id int not null,
  constraint pk_user_role primary key (user_id,role_id),
  constraint fk_user_role_1 foreign key (user_id) REFERENCES users(ID),
  constraint fk_user_role_2 foreign key (role_id) REFERENCES roles(ID)
);

/*
  表名称: permissions  (权限)
  name    权限名称
  descn   描述
  operation 操作
  status 状态
*/
create table permissions
(
  id            int not null identity,
  name          varchar(80) not null,
  descn         varchar(255) null,
  operation     varchar(80) null,
  status VARCHAR(2) default '1',
  constraint pk_permissons primary key (id)
);

/*
  表名称: role_permis(角色权限)
  role_id 角色ID
  permis_id 权限ID
*/
create table role_permis
(
  role_id int not null,
  permis_id int not null,
  constraint pk_role_permis primary key (role_id,permis_id),
  constraint fk_role_role_permis_1 foreign key (role_id) REFERENCES roles(ID),
  constraint fk_role_role_permis_2 foreign key (permis_id) REFERENCES permissions(ID)
);

/*
  表名称: resources  (资源)
  name  资源名称(模块名称)
  res_type 资源类型
  res_string 资源串
  descn  资源描述
*/
create table resources
(
  id            int not null identity,
  name          varchar(80) not null,
  res_type varchar(20) not null,
  res_string varchar(255) not null,
  descn         varchar(255) null,
  constraint pk_resources primary key (id)
);

/*
  表名称: permis_resc(权限资源)
  resource_id   资源ID
  operation_id  操作ID

*/
create table permis_resc
(
  permis_id  int not null,
  resc_id   int not null,
  constraint pk_permis_resc primary key (permis_id,resc_id),
  constraint fk_role_permis_resc_1 foreign key (resc_id) REFERENCES resources(ID),
  constraint fk_role_permis_resc_2 foreign key (permis_id) REFERENCES permissions(ID)
);

/*
  表名称: acl_object_identity(保护的ACLDomain对象列表)
  object_identity   受保护的ACL对象的标识符,一般是ClassName + ID
  parent_object  该对象关联的父对象
  acl_class  Acegi用来描述该类的Class,一般用来表示Mark等信息
*/
create table acl_object_identity (
  id            int not null identity,
  object_identity varchar(250) not null,
  parent_object integer,
  acl_class varchar(250) NOT NULL,
  constraint unique_object_identity unique(object_identity), 
  foreign key (parent_object) REFERENCES acl_object_identity(id)
);

/*
  表名称: permis_resc(ACL授权列表)
  acl_object_identity   对应acl_object_identity表的id,表示一个Acl保护的对象。
  recipient  用户名或角色名
  mask  所授权限
*/
create table acl_permission (
  id            int not null identity,
  acl_object_identity integer not null,
  recipient varchar(100) NOT NULL,
  mask integer not null,
  constraint unique_recipient unique(acl_object_identity, recipient),
  foreign key (acl_object_identity) REFERENCES acl_object_identity(id)
);


大盘预测 国富论
posted on 2008-01-21 20:19 华梦行 阅读(198) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: