⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tables.sql

📁 基于J2EE技术的 电子购物商城系统
💻 SQL
字号:
drop table trades;
drop table carts;
drop table books;
drop table goods;
drop table categories#3;
drop table categories#2;
drop table categories#1;
drop table users;

/* 1. users(6个字段)
 **************************************************************************************************************************
 * table name:
 *      users
 * data desciption: 
 *      storage the users' information.
 **************************************************************************************************************************
*/
create table users
(
 id			varchar2(18)	primary key,								/*用户ID*/
 password	varchar2(18)	not null,									/*用户密码*/
 name		varchar2(18)	not null,									/*用户名字*/
 gender		char(2)			not null check(gender='男' or gender='女'),	/*用户性别*/
 balance	number(8, 2)	not null check(balance>=0),					/*用户余额*/
 note		varchar2(33)												/*用户备注信息*/
);


/* 2.categories
 **************************************************************************************************************************
 * table name: 
 *      categories
 * data desciption: 
 *      storage the categories' information.
 **************************************************************************************************************************
*/
create table categories#1								/*一级商品类别表*/
(
 category	varchar2(18)	primary key						/*商品类别*/
);

create table categories#2								/*二级商品类别表*/
(
 category	varchar2(18)	primary key						/*商品类别*/
);

create table categories#3								/*三级商品类别表*/
(
 category	varchar2(18)	primary key						/*商品类别*/
);


/* 3.goods(9个字段)
 **************************************************************************************************************************
 * table name:
 *      goods
 * data desciption: 
 *      storage the goods' information.
 **************************************************************************************************************************
*/
create table goods
(
 id			varchar2(33)	primary key,								/*商品ID*/
 name		varchar2(33)	not null,									/*商品名称*/
 price		number(6, 2)	not null check(price >= 0),					/*商品单价*/
 num		number(4)		not null check(num >= 0),					/*商品库存*/
 salerId	varchar2(18)	not null references users(id),				/*商品的卖方ID*/
 category#1	varchar2(18)	references categories#1(category),			/*商品的一级分类*/
 category#2	varchar2(18)	references categories#2(category),			/*商品的二级分类*/
 category#3	varchar2(18)	references categories#3(category),			/*商品的三级分类*/
 isReleased	number(1)		not null check(isReleased=0 or isReleased=1)/*商品是否已经发布*/
);


/* 4.books(13个字段)
 **************************************************************************************************************************
 * table name:
 *      books
 * data desciption: 
 *      storage the books' information.
 **************************************************************************************************************************
*/
create table books
(
 id			varchar2(33)	primary key,								/*图书ID*/
 name		varchar2(33)	not null,									/*图书名称*/
 price		number(6, 2)	not null check(price >= 0),					/*图书单价*/
 num		number(4)		not null check(num >= 0),					/*图书库存*/
 salerId	varchar2(18)	not null references users(id),				/*图书的卖方ID*/
 category#1	varchar2(18)	references categories#2(category),			/*图书的一级分类*/
 category#2	varchar2(18)	references categories#3(category),			/*图书的二级分类*/
 author		varchar2(33)	,											/*图书作者*/
 press		varchar2(33)	,											/*出版社*/
 edition	number(1)		,											/*图书版本*/
 isbn		varchar2(33)	,											/*国际统一图书编号*/
 categoryNUM varchar2(33)	,											/*中国图书分类号*/
 isReleased	number(1)		not null check(isReleased=0 or isReleased=1)/*图书是否已经发布*/
);

/* 5.carts(4个字段)
 **************************************************************************************************************************
 * table name:
 *      carts
 * data desciption: 
 *      storage the carts' information.
 **************************************************************************************************************************
*/
create table carts
(
 userId		varchar2(18)	references users(id),								/*购物车的用户ID*/
 goodId		varchar2(33)	,													/*购物车中的某商品ID*/
 goodCount	number(4)	not null check(goodCount>0),							/*购物车中的某商品数量*/
 goodType	char(8)		not null check(goodType='图书' or goodType='普通商品'),	/*购物车中的某商品类型*/
 primary key(userId, goodId, goodType)
);


/* 6.trades(9个字段)
 **************************************************************************************************************************
 * table name:
 *      trades
 * data desciption: 
 *      storage the trades' information.
 **************************************************************************************************************************
*/
create table trades
(
 id			varchar2(50)	primary key,								/*交易编号*/
 listId		varchar2(50)	,											/*定单号,当且仅当成功完成定单中的所有交易时,系统才会生成此号*/
 buyerId	varchar2(18)	not null references users(id),				/*商品的买方ID*/
 salerId	varchar2(18)	not null references users(id),				/*商品的卖方ID*/
 goodId		varchar2(33)	,											/*商品的ID*/
 goodCount	number(4)		not null check(goodCount>0),				/*购买数量*/
 goodType	char(8)			not null check(goodType='图书' or goodType='普通商品'),	/*购买的商品类型*/
 isPayed	number(1)		check(isPayed=0 or isPayed=1),				/*是否完成支付*/
 isSuccessful	number(1)	check(isSuccessful=0 or isSuccessful=1)	/*是否成功完成定单中的所有交易*/
);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -