A. 電子商務網站怎樣的資料庫設計
個人建議去購買成熟的電子商務網站平台,目前已經有許多CMS系統都非常完善,功能也很齊全了,與其自己設計資料庫,不如去購買現成的,如果不願意掏錢,當然也有免費的B2B網站系統,例如SHOPEX,ECSHOP等等都是免費的。
B. 購物網站資料庫表如何設計
去下載那些知名的網點系統來看看資料庫設計部就可以了
C. C#,做在線商城,資料庫表設計問題。
樓主的需求可以做到。
1、商品分類表(tbType)
---------------------------------------------
id(key) typeName
---------------------------------------------
0 手機
1 食物
2、額外屬性表(tbAttribute)
---------------------------------------------
id(key) attributeName
---------------------------------------------
0 有效期
1 操作系統
2 配料
3、屬性關聯表(tbAttributeRelation)
---------------------------------------------
typeId attributeId
---------------------------------------------
0 1
1 0
1 2
4、商品表(tbGoods)
---------------------------------------------
id(key) type name price 共同欄位……
---------------------------------------------
0 0 NOKIA 2000 ……
1 1 A牌肉包 30 ……
2 1 B牌菜包 10 ……
5、屬性詳細表(tbDetail)
---------------------------------------------
id(key) attributeId(key) value
---------------------------------------------
0 1 塞班S60V3
1 0 3天
1 2 麵粉,精肉
2 0 4天
2 2 麵粉,青菜
這樣就可以了。謝謝採納。
如果需要增加一個屬性,在 2、額外屬性表(tbAttribute)增加一條記錄 和 3、屬性關聯表(tbAttributeRelation)里增加一條關聯。然後就可以去 5、屬性詳細表(tbDetail)里存儲這個屬性的值。例如我要為手機增加一個續航能力的屬性。
只需要
2、額外屬性表(tbAttribute)
---------------------------------------------
id(key) attributeName
---------------------------------------------
0 有效期
1 操作系統
2 配料
3 續航能力 《---新增的
3、屬性關聯表(tbAttributeRelation)
---------------------------------------------
typeId attributeId
---------------------------------------------
0 1
1 0
1 2
0 3 《---新增的
5、屬性詳細表(tbDetail)
---------------------------------------------
id(key) attributeId(key) value
---------------------------------------------
0 1 塞班S60V3
1 0 3天
1 2 麵粉,精肉
2 0 4天
2 2 麵粉,青菜
0 3 900小時 《---新增的
這樣的設計看起來麻煩。但其實並不麻煩。
不僅能夠動態增加任意的分類和分類的任意獨特屬性。
還可以讓不同分類之間相同的屬性復用。達到資料庫的最小耦合。
D. 購物網站資料庫設計
一、概述
網上購物店的數據模型,主要模式有產品:proct ,帳戶:Account,定單:Order。和產品相關的表有category ,proct,item, inventory, supplier;和用戶相關表有的account ,signon,profile;和定單相關的表有orders,orderstatus,lineitem ,整體關系如下.
二、帳戶模型
帳戶模型,記錄者用戶的登錄名稱,密碼。以及個人信息如地址,性名,電話等,還有它在系統中的profile信息。表有Account 主鍵是userID,它記錄用戶的基本信息,如email,name等。Signon 表記錄者userID和password,Profile表記錄者用戶的登錄系統的系統設置。可以根據用戶的類型,顯示不同的登錄信息。
(1)account表
create table account (
userid varchar(80) not null,
email varchar(80) not null,
name varchar(80) not null,
status char(2) null,
addr1 varchar(80) not null,
addr2 varchar(40) null,
city varchar(80) not null,
state varchar(80) not null,
zip varchar(20) not null,
country varchar(20) not null,
phone varchar(80) not null,
constraint pk_account primary key (userid)
)
說明:primary key是userID,它記錄帳戶的基本信息。
(2)Signon 表
create table signon (
username varchar(25) not null,
password varchar(25) not null,
constraint pk_signon primary key (username)
)
說明:記錄登錄名和密碼。
(3)Profile表
create table profile (
userid varchar(80) not null,
langpref varchar(80) not null,
favcategory varchar(30),
mylistopt int,
banneropt int,
constraint pk_profile primary key (userid)
)
說明:用戶的登錄信息,方便個性化定製。
(4)Bannerdata 表
create table bannerdata (
favcategory varchar(80) not null,
bannername varchar(255) null,
constraint pk_bannerdata primary key (favcategory)
)
說明:記錄不同的登錄信息。
三、產品模型
產品的模型主要有分類,它是產品的大類。表category 就是記錄分類名稱,描述信息。Proct
記錄每個產品的基本信息,包括產品名稱,和產品的描述。它是一對多的關系。Supplier 表
記錄產品的提供者信息,包括提供者的名稱,地址,狀態等。Item 記錄產品的提供者,產
品ID,價格,狀態。Inventory 表記錄產品的數量。關系如下:
(1) category表
create table category (
catid char(10) not null,
name varchar(80) null,
descn varchar(255) null,
constraint pk_category primary key (catid)
)
(2)proct表
create table proct (
proctid char(10) not null,
category char(10) not null,
name varchar(80) null,
descn varchar(255) null,
constraint pk_proct primary key (proctid),
constraint fk_proct_1 foreign key (category)
references category (catid)
)
(3) item表
create table item (
itemid char(10) not null,
proctid char(10) not null,
listprice decimal(10,2) null,.unitcost decimal(10,2) null,
supplier int null,
status char(2) null,
attr1 varchar(80) null,
attr2 varchar(80) null,
attr3 varchar(80) null,
attr4 varchar(80) null,
attr5 varchar(80) null,
constraint pk_item primary key (itemid),
constraint fk_item_1 foreign key (proctid)
references proct (proctid),
constraint fk_item_2 foreign key (supplier)
references supplier (suppid)
)
(4) inventory 表
create table inventory (
itemid char(10) not null,
qty int not null
)
(5)supplier表
create table inventory (
suppid int not null
name varchar(80)
status char(2)
attr1 varchar(80)
attr2 varchar(80)
city varchar(80)
state varchar(80)
zip char(6)
phone varchar(80)
constraint pk_supplier primary key (suppid),
)
四、定單模型
定單記錄用戶的選擇產品信息,數量,表主要有Orders,記錄用戶的地址,帳戶信息,總金
額。Orderstatus 記錄定單狀態。Lineitem 記錄定單中的產品數量,單位價格,產品ID。
(1)orders表
create table orders (
orderid int not null,
userid varchar(80) not null,
orderdate date not null,
shipaddr1 varchar(80) not null,
shipaddr2 varchar(80) null,
shipcity varchar(80) not null,
shipstate varchar(80) not null,
shipzip varchar(20) not null,
shipcountry varchar(20) not null,
billaddr1 varchar(80) not null,
billaddr2 varchar(80) null,
billcity varchar(80) not null,
billstate varchar(80) not null,
billzip varchar(20) not null,
billcountry varchar(20) not null,
courier varchar(80) not null,
totalprice number(10,2) not null,
billtoname varchar(80) not null,
shiptoname varchar(80) not null,
creditcard varchar(80) not null,
exprdate char(7) not null,
cardtype varchar(80) not null,
locale varchar(20) not null,
constraint pk_orders primary key (orderid),
constraint fk_orders_1 foreign key (userid)
references account (userid)
)
定單的信息。
(2)Orderstatus表
create table orderstatus (
orderid int not null,
linenum int not null,
timestamp date not null,
status char(2) not null,
constraint pk_orderstatus primary key (orderid, linenum),
constraint fk_orderstatus_1 foreign key (orderid)
references orders (orderid)
)
定單中的產品狀態
(3)lineitem表
create table lineitem (
orderid int not null,
linenum int not null,
itemid char(10) not null,
quantity int not null,
unitprice number(10,2) not null,
constraint pk_lineitem primary key (orderid, linenum),
constraint fk_lineitem_1 foreign key (orderid)
references orders (orderid)
)
E. 關於購物網站的資料庫設計問題
不要這樣,這樣你會有無數多的表,而且以後新的一個產品時候非常麻煩,如果要屬於新的類別,而且還會因為避免資料庫太復雜而使得許多不同類的產品歸在一個類。而且你的程序很麻煩,要為每個類編寫不同程序,因為數據表名不同。
應該用下面的辦法,主要使用四個表存儲所有類別的商品:
第一、類別名稱表,欄位有
類別ID,類別名稱
1 電腦
2 洗衣機
第二、類別屬性表,欄位有:
類別ID,屬性ID,屬性名稱
1 1 CPU
1 2 內存
1 3 屏幕尺寸
2 1 容量
2 2 類型
第三、商品名稱表,欄位有:
商品ID,類別ID
1 1
2 1
3 2
4 2
第四、商品屬性表,欄位有:
商品ID,屬性ID,屬性值
1 1 P4
1 2 128M
1 3 CRT 14
2 1 P4
2 2 512M
2 3 LCD19
3 1 9公斤
3 2 滾筒
4 1 8公斤
4 2 波輪
上面定義了四個商品,商品ID為1~4,分別是128M、512M內存的電腦,和9公斤滾筒、8公斤的波輪洗衣機。
這樣定義的資料庫結構,可以包含任何商品,一般不會改變,那麼程序也就無需改變,定義新的產品、或者修改現有商品只需要在程序界面有操作員點點滑鼠。
F. 電商項目---資料庫表設計
CREATE TABLE `mmall_user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用戶表id',
`username` varchar(50) NOT NULL COMMENT '用戶名',
`password` varchar(50) NOT NULL COMMENT '用戶密碼,MD5加密',
`email` varchar(50) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`question` varchar(100) DEFAULT NULL COMMENT '找回密碼問題',
`answer` varchar(100) DEFAULT NULL COMMENT '找回密碼答案',
`role` int(4) NOT NULL COMMENT '角色0-管理員,1-普通用戶',
`create_time` datetime NOT NULL COMMENT '創建時間',
`update_time` datetime NOT NULL COMMENT '最後一次更新時間',
PRIMARY KEY (`id`),
UNIQUE KEY `user_name_unique` (`username`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_proct` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品id',
`category_id` int(11) NOT NULL COMMENT '分類id,對應mmall_category表的主鍵',
`name` varchar(100) NOT NULL COMMENT '商品名稱',
`subtitle` varchar(200) DEFAULT NULL COMMENT '商品副標題',
`main_image` varchar(500) DEFAULT NULL COMMENT '產品主圖,url相對地址',
`sub_images` text COMMENT '圖片地址,json格式,擴展用',
`detail` text COMMENT '商品詳情',
`price` decimal(20,2) NOT NULL COMMENT '價格,單位-元保留兩位小數',
`stock` int(11) NOT NULL COMMENT '庫存數量',
`status` int(6) DEFAULT '1' COMMENT '商品狀態.1-在售 2-下架 3-刪除',
`create_time` datetime DEFAULT NULL COMMENT '創建時間',
`update_time` datetime DEFAULT NULL COMMENT '更新時間',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_category` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '類別Id',
`parent_id` int(11) DEFAULT NULL COMMENT '父類別id當id=0時說明是根節點,一級類別',
`name` varchar(50) DEFAULT NULL COMMENT '類別名稱',
`status` tinyint(1) DEFAULT '1' COMMENT '類別狀態1-正常,2-已廢棄',
`sort_order` int(4) DEFAULT NULL COMMENT '排序編號,同類展示順序,數值相等則自然排序',
`create_time` datetime DEFAULT NULL COMMENT '創建時間',
`update_time` datetime DEFAULT NULL COMMENT '更新時間',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=100031 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_order` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '訂單id',
`order_no` bigint(20) DEFAULT NULL COMMENT '訂單號',
`user_id` int(11) DEFAULT NULL COMMENT '用戶id',
`shipping_id` int(11) DEFAULT NULL,
`payment` decimal(20,2) DEFAULT NULL COMMENT '實際付款金額,單位是元,保留兩位小數',
`payment_type` int(4) DEFAULT NULL COMMENT '支付類型,1-在線支付',
`postage` int(10) DEFAULT NULL COMMENT '運費,單位是元',
`status` int(10) DEFAULT NULL COMMENT '訂單狀態:0-已取消-10-未付款,20-已付款,40-已發貨,50-交易成功,60-交易關閉',
`payment_time` datetime DEFAULT NULL COMMENT '支付時間',
`send_time` datetime DEFAULT NULL COMMENT '發貨時間',
`end_time` datetime DEFAULT NULL COMMENT '交易完成時間',
`close_time` datetime DEFAULT NULL COMMENT '交易關閉時間',
`create_time` datetime DEFAULT NULL COMMENT '創建時間',
`update_time` datetime DEFAULT NULL COMMENT '更新時間',
PRIMARY KEY (`id`),
UNIQUE KEY `order_no_index` (`order_no`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_order_item` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '訂單子表id',
`user_id` int(11) DEFAULT NULL,
`order_no` bigint(20) DEFAULT NULL,
`proct_id` int(11) DEFAULT NULL COMMENT '商品id',
`proct_name` varchar(100) DEFAULT NULL COMMENT '商品名稱',
`proct_image` varchar(500) DEFAULT NULL COMMENT '商品圖片地址',
`current_unit_price` decimal(20,2) DEFAULT NULL COMMENT '生成訂單時的商品單價,單位是元,保留兩位小數',
`quantity` int(10) DEFAULT NULL COMMENT '商品數量',
`total_price` decimal(20,2) DEFAULT NULL COMMENT '商品總價,單位是元,保留兩位小數',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `order_no_index` (`order_no`) USING BTREE,
KEY `order_no_user_id_index` (`user_id`,`order_no`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_cart` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`proct_id` int(11) DEFAULT NULL COMMENT '商品id',
`quantity` int(11) DEFAULT NULL COMMENT '數量',
`checked` int(11) DEFAULT NULL COMMENT '是否選擇,1=已勾選,0=未勾選',
`create_time` datetime DEFAULT NULL COMMENT '創建時間',
`update_time` datetime DEFAULT NULL COMMENT '更新時間',
PRIMARY KEY (`id`),
KEY `user_id_index` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_pay_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL COMMENT '用戶id',
`order_no` bigint(20) DEFAULT NULL COMMENT '訂單號',
`pay_platform` int(10) DEFAULT NULL COMMENT '支付平台:1-支付寶,2-微信',
`platform_number` varchar(200) DEFAULT NULL COMMENT '支付寶支付流水號',
`platform_status` varchar(20) DEFAULT NULL COMMENT '支付寶支付狀態',
`create_time` datetime DEFAULT NULL COMMENT '創建時間',
`update_time` datetime DEFAULT NULL COMMENT '更新時間',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8;
CREATE TABLE `mmall_shipping` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL COMMENT '用戶id',
`receiver_name` varchar(20) DEFAULT NULL COMMENT '收貨姓名',
`receiver_phone` varchar(20) DEFAULT NULL COMMENT '收貨固定電話',
`receiver_mobile` varchar(20) DEFAULT NULL COMMENT '收貨行動電話',
`receiver_province` varchar(20) DEFAULT NULL COMMENT '省份',
`receiver_city` varchar(20) DEFAULT NULL COMMENT '城市',
`receiver_district` varchar(20) DEFAULT NULL COMMENT '區/縣',
`receiver_address` varchar(200) DEFAULT NULL COMMENT '詳細地址',
`receiver_zip` varchar(6) DEFAULT NULL COMMENT '郵編',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
GitHub 地址:https://github.com/Andy-leoo/NewBieJavaPro.git
G. 購物網站資料庫設計
一、概述
網上購物店的數據模型,主要模式有產品:proct ,帳戶:Account,定單:Order。和產品相關的表有category ,proct,item, inventory, supplier;和用戶相關表有的account ,signon,profile;和定單相關的表有orders,orderstatus,lineitem ,整體關系如下.
二、帳戶模型
帳戶模型,記錄者用戶的登錄名稱,密碼。以及個人信息如地址,性名,電話等,還有它在系統中的profile信息。表有Account 主鍵是userID,它記錄用戶的基本信息,如email,name等。Signon 表記錄者userID和password,Profile表記錄者用戶的登錄系統的系統設置。可以根據用戶的類型,顯示不同的登錄信息。
(1)account表
create table account (
userid varchar(80) not null,
email varchar(80) not null,
name varchar(80) not null,
status char(2) null,
addr1 varchar(80) not null,
addr2 varchar(40) null,
city varchar(80) not null,
state varchar(80) not null,
zip varchar(20) not null,
country varchar(20) not null,
phone varchar(80) not null,
constraint pk_account primary key (userid)
)
說明:primary key是userID,它記錄帳戶的基本信息。
(2)Signon 表
create table signon (
username varchar(25) not null,
password varchar(25) not null,
constraint pk_signon primary key (username)
)
說明:記錄登錄名和密碼。
(3)Profile表
create table profile (
userid varchar(80) not null,
langpref varchar(80) not null,
favcategory varchar(30),
mylistopt int,
banneropt int,
constraint pk_profile primary key (userid)
)
說明:用戶的登錄信息,方便個性化定製。
(4)Bannerdata 表
create table bannerdata (
favcategory varchar(80) not null,
bannername varchar(255) null,
constraint pk_bannerdata primary key (favcategory)
)
說明:記錄不同的登錄信息。
三、產品模型
產品的模型主要有分類,它是產品的大類。表category 就是記錄分類名稱,描述信息。Proct
記錄每個產品的基本信息,包括產品名稱,和產品的描述。它是一對多的關系。Supplier 表
記錄產品的提供者信息,包括提供者的名稱,地址,狀態等。Item 記錄產品的提供者,產
品ID,價格,狀態。Inventory 表記錄產品的數量。關系如下:
(1) category表
create table category (
catid char(10) not null,
name varchar(80) null,
descn varchar(255) null,
constraint pk_category primary key (catid)
)
(2)proct表
create table proct (
proctid char(10) not null,
category char(10) not null,
name varchar(80) null,
descn varchar(255) null,
constraint pk_proct primary key (proctid),
constraint fk_proct_1 foreign key (category)
references category (catid)
)
(3) item表
create table item (
itemid char(10) not null,
proctid char(10) not null,
listprice decimal(10,2) null,.unitcost decimal(10,2) null,
supplier int null,
status char(2) null,
attr1 varchar(80) null,
attr2 varchar(80) null,
attr3 varchar(80) null,
attr4 varchar(80) null,
attr5 varchar(80) null,
constraint pk_item primary key (itemid),
constraint fk_item_1 foreign key (proctid)
references proct (proctid),
constraint fk_item_2 foreign key (supplier)
references supplier (suppid)
)
(4) inventory 表
create table inventory (
itemid char(10) not null,
qty int not null
)
(5)supplier表
create table inventory (
suppid int not null
name varchar(80)
status char(2)
attr1 varchar(80)
attr2 varchar(80)
city varchar(80)
state varchar(80)
zip char(6)
phone varchar(80)
constraint pk_supplier primary key (suppid),
)
四、定單模型
定單記錄用戶的選擇產品信息,數量,表主要有Orders,記錄用戶的地址,帳戶信息,總金
額。Orderstatus 記錄定單狀態。Lineitem 記錄定單中的產品數量,單位價格,產品ID。
(1)orders表
create table orders (
orderid int not null,
userid varchar(80) not null,
orderdate date not null,
shipaddr1 varchar(80) not null,
shipaddr2 varchar(80) null,
shipcity varchar(80) not null,
shipstate varchar(80) not null,
shipzip varchar(20) not null,
shipcountry varchar(20) not null,
billaddr1 varchar(80) not null,
billaddr2 varchar(80) null,
billcity varchar(80) not null,
billstate varchar(80) not null,
billzip varchar(20) not null,
billcountry varchar(20) not null,
courier varchar(80) not null,
totalprice number(10,2) not null,
billtoname varchar(80) not null,
shiptoname varchar(80) not null,
creditcard varchar(80) not null,
exprdate char(7) not null,
cardtype varchar(80) not null,
locale varchar(20) not null,
constraint pk_orders primary key (orderid),
constraint fk_orders_1 foreign key (userid)
references account (userid)
)
定單的信息。
(2)Orderstatus表
create table orderstatus (
orderid int not null,
linenum int not null,
timestamp date not null,
status char(2) not null,
constraint pk_orderstatus primary key (orderid, linenum),
constraint fk_orderstatus_1 foreign key (orderid)
references orders (orderid)
)
定單中的產品狀態
(3)lineitem表
create table lineitem (
orderid int not null,
linenum int not null,
itemid char(10) not null,
quantity int not null,
unitprice number(10,2) not null,
constraint pk_lineitem primary key (orderid, linenum),
constraint fk_lineitem_1 foreign key (orderid)
references orders (orderid)
)
H. 多用戶商城資料庫如何設計
差不多都是一個 文章表,用戶表,分類表,設置表。
1、資料庫分離成前台和後台,通過鏈接表關聯;
2、把前台做成彈出窗體,禁止用戶使用導航選項和菜單之類;
3、把前台編譯成ACCESS2007的accde文件(對應ACCESS2003的mde文件);
4、把這個accde文件也放在伺服器端,客戶端通過winform之類exe來遠程打開。
前3步都比較正常,第4步的看起來應該比較奇怪。我的想法是,如果accde文件也放在客戶端,高手會不會通過反編譯就可以進入到資料庫看到鏈接表?感覺上「禁止Shift」,「隱藏表」這類手段只對菜鳥有用。