ylbtech-dbs:ylbtech-m-ele(餓了么) |
-- =============================================-- DatabaseName:Ele
-- desc:餓了么(外賣網(wǎng))-- pubdate:10:41 2014-06-23-- author:ylbtech-- http://m.ele.me-- =============================================
1.A,數(shù)據(jù)庫(kù)關(guān)系圖(Database Diagram) 返回頂部 |
1.B,數(shù)據(jù)庫(kù)設(shè)計(jì)腳本(Database Design Script)返回頂部 |
1.B.1,
1.B.1.1, sql-basic.sql
-- =============================================-- DatabaseName:Ele-- pubdate:10:41 2014-06-23-- author:ylbtech-- http://m.ele.me-- =============================================USE masterGO-- Drop the database if it already existsIF EXISTS ( SELECT name FROM sysdatabases WHERE name = N'ele')DROP DATABASE eleGOCREATE DATABASE eleGOuse elegogo-- =============================================-- ylb:1,用戶表-- =============================================create table Account(account_id int PRimary key identity(10000,1), --編號(hào)【PK】username varchar(40) unique not null, --用戶名【UQ】[passWord] varchar(40) not null, --密碼email varchar(60) not null, --電子郵箱pubdate datetime default(getdate()), --時(shí)間flag bit default(0) --標(biāo)識(shí)帳號(hào)是否激活 0:未激活;1:以激活)go-- =============================================-- ylb:1,我的地址-- =============================================create table [Address](address_id int primary key identity(10000,1), --編號(hào)【PK】[address] varchar(40) not null, --詳細(xì)地址phone varchar(40) not null, --聯(lián)系電話phone_bk varchar(40) not null, --備選電話flag bit default(0), --0:;1:默認(rèn)送餐地址account_id int foreign key references Account(account_id), --賬戶ID【FK】 )go--drop table FeedBackGO-- =============================================-- ylb: 6, 反饋留言-- =============================================create table Feedback(feedback_id int primary key identity(1,1), --編號(hào)【PK,ID】content varchar(200), --內(nèi)容pubdate datetime default(getdate()), --時(shí)間[type] int, --類型[status] int, --狀態(tài)reply_content varchar(200), --回復(fù)內(nèi)容reply_pubdate datetime, --回復(fù)日期account_type int, --用戶類型account_id int foreign key references Account(account_id) --賬戶ID【FK】 )go -- ============================================= -- 2,標(biāo)簽 【公共】-- ============================================= create table Tag ( tag_id int identity(1,1) primary key, --類別ID [PK] tag_name varchar(100), --標(biāo)簽名稱 tag_img varchar(100), --標(biāo)簽圖片[description] varchar(400), --描述flag bit default(0) --是否禁用) --drop table Place--drop table Citygo-- =============================================-- ylb:1,城市【公共】-- =============================================create table City(city_id varchar(20) primary key, --編號(hào)【PK】city_name varchar(40) unique not null, --城市名【UQ】flag bit default(0) --0:;1:是否禁用)go-- =============================================-- ylb:1,城市【公共】-- =============================================create table Place(place_id int unique identity(10000,1), --編號(hào)【UQ】place_name varchar(40) unique not null, --地址名稱address varchar(40) not null, --地址flag bit default(0), --0:;1:是否禁用city_id varchar(20) foreign key references City(city_id), --賬戶ID【FK】 )gogo-- =============================================-- ylb:1,用戶表_商戶-- =============================================create table AccountShop(account_shop_id int primary key identity(10000,1), --編號(hào)【PK】username varchar(40) unique not null, --用戶名【UQ】[password] varchar(40) not null, --密碼email varchar(60) not null, --電子郵箱pubdate datetime default(getdate()), --時(shí)間flag bit default(0) --標(biāo)識(shí)帳號(hào)是否激活 0:未激活;1:以激活)go-- =============================================-- ylb:1,店鋪-- =============================================create table Shop(shop_id int primary key identity(10000,1), --編號(hào)【UQ】shop_name varchar(500) unique not null, --商鋪名稱logo_img varchar(500) not null, --商標(biāo)圖片opening_time varchar(500) not null, --營(yíng)業(yè)時(shí)間begin_price varchar(500) not null, --起送價(jià)[address] varchar(500) not null, --地址intro varchar(500) not null, --簡(jiǎn)介notice varchar(500) not null, --公告location varchar(40) not null, --商鋪所在位置[status] varchar(40), --狀態(tài) 營(yíng)業(yè)中|休息中--distance varchar(40) not null, --距離account_shop_id int foreign key references AccountShop(account_shop_id) --商戶賬戶ID【FK】 )go -- ============================================= -- 2,類別 -- ============================================= create table Category ( category_id int identity(10000,1) primary key, --類別ID [PK] category_name varchar(40) not null, --類別名稱 [description] varchar(400), --說(shuō)明 picture varchar(40), --圖片flag bit default(0), --是否禁用shop_id int foreign key references Shop(shop_id) --商鋪ID【FK】 ) go--drop table Product go -- ============================================= --3,產(chǎn)品 -- ============================================= create table Product( product_id int identity primary key, --產(chǎn)品ID『PK』 product_name varchar(400) not null, --產(chǎn)品名稱 product_img varchar(400), --圖片quantity_per_unit varchar(40), --規(guī)格 unit_price decimal(8,2), --單價(jià) units_in_stock int default(0) check(units_in_stock>=0), --庫(kù)存量 units_on_order int default(0) check(units_on_order>=0), --訂購(gòu)量--reorder_level int default(0) check(reorder_level>=0), --再訂購(gòu)量 flag bit default(0), --是否禁用category_id int foreign key references Category(category_id), --類別ID shop_id int foreign key references Shop(shop_id), --帳戶編號(hào)【FK】關(guān)聯(lián)與帳戶設(shè)置flag_hotfood bit default(0) --是否推薦) --drop table Commentgo -- ============================================= -- 4,菜品評(píng)價(jià) -- ============================================= create table Comment(comment_id int identity primary key, --編號(hào)【PK,ID】content varchar(400), --內(nèi)容pubdate datetime default(getdate()), --評(píng)價(jià)日期account_id int foreign key references Account(account_id), --賬戶ID【FK】 shop_id int foreign key references Shop(shop_id), --帳戶編號(hào)【FK】關(guān)聯(lián)與帳戶設(shè)置product_id int foreign key references Product(product_id), --菜品ID【FK】 )go -- ============================================= -- 7,訂單 -- ============================================= create table [Order]( order_id int identity primary key, --訂單ID【PK】 account_id int foreign key references Account(account_id), --賬戶ID【FK】 shop_id int foreign key references Shop(shop_id), --商鋪ID【FK】 order_date datetime, --訂購(gòu)日期 required_date datetime, --到貨日期 total decimal(8,2), --合計(jì)金額shipped_date datetime, --發(fā)貨日期 ShipVia int, --運(yùn)貨商【FK】 fright decimal(8,2), --運(yùn)貨費(fèi) ship_name varchar(15), --貨主名稱 ship_address varchar(60), --貨主地址 ship_city varchar(15), --貨主城市 ship_region varchar(15), --貨主地區(qū) ship_contry varchar(15), --貨主國(guó)家 ship_postal_code varchar(10),--貨主郵政編碼[status] int, --狀態(tài)flag bit default(0), --是否禁用deliver_time varchar(40), --送餐時(shí)間remark varchar(400), --備注[type] int --外賣|預(yù)訂|就餐) go--drop table [Order]--drop table OrderDetailsgo -- ============================================= -- 4,訂單明細(xì) -- ============================================= create table OrderDetails( order_id int, --訂單ID【UPK】 product_id int, --產(chǎn)品ID【UPK】 unit_price decimal(8,2) not null, --單價(jià) quantity int not null, --數(shù)量 --discount decimal(8,2) not null, --折扣 [name] varchar(400), --名稱stat
新聞熱點(diǎn)
疑難解答
圖片精選