book
1
create database book
2
use book
3
go
4
5
--1.图书类别分类表 bookClass
6
create table bookClass
7
(
8
class_id int identity primary key,--编号
9
class_name varchar(100) not null, --名称
10
class_parent int default 0--父类
11
)
12
13
--2.图书信息 book
14
create table book
15
(
16
book_id int identity primary key,--书籍编号
17
book_name varchar(200) not null,--图书名称
18
class_id int not null,--图书类别 与bookClass表对应
19
book_come varchar(200),--出版社
20
book_author varchar(200) not null,--作者
21
book_price varchar(10) not null,--定价
22
book_price1 varchar(10) not null,--买出时的价钱
23
book_ISBN varchar(50),--ISBN
24
book_time datetime, --出版日期
25
book_disk varchar(100),--光盘数
26
book_volume varchar(100),--册数
27
book_image varchar(200),--图片路径
28
book_text text, --书籍说明,内容简介
29
book_key varchar(200),--关键字,多个关键字之间用逗号隔开
30
book_date datetime default GETDATE(),--添加日期
31
book_isDel int default 0--图书是否删除,0正常未被删除,1被删除,从BIT型改为INT型,2通过审核还没有生成静态页面
32
)
33
34
--book_name,class_id,book_come,book_author,book_price,book_price1,book_ISBN,book_time,book_disk,book_volume,book_image,book_text,book_key
35
36
--3.图书属性 book_attribute 推荐 热销 关注
37
create table book_attribute
38
(
39
ba_id int identity primary key,--编号
40
ba_name varchar(50) not null,--名称
41
)
42
43
--4.推荐、热销、关注等表图书表
44
create table RS
45
(
46
id int identity primary key,--编号
47
book_id int not null,--书籍编号,与book表中的书籍编号关联
48
rs_date datetime default GETDATE(), --日期
49
ba_id int not null --属性编号,与book_attribute表关联
50
)
51
52
--5.书店讯息 new
53
create table new
54
(
55
new_id int identity primary key,--编号
56
new_title varchar(200) not null,--标题
57
new_content text not null,--内容
58
new_date datetime default getdate() --添加时间
59
)
60
61
--6.用户注册信息 user
62
create table [user]
63
(
64
[user_id] int identity primary key,--编号
65
[user_name] varchar(100) not null,--用户名称
66
user_pass varchar(32) not null,--密码
67
user_mail varchar(100) not null, --邮箱
68
user_quest varchar(200),--问题
69
user_answer varchar(200),--答案
70
user_money float default 0, --存取在本站的金额
71
user_receive int default 0 --积分
72
)
73
74
--7.后台管理员信息 admin
75
create table admin
76
(
77
admin_id int identity primary key,--编号
78
admin_name varchar(100) not null,--管理员名称
79
admin_pass varchar(32) not null, --密码
80
--权限
81
admin_class int default 1 --用户类别,0管理员,1普通管理员
82
)
83
84
--8.操作日志 log
85
create table [log]
86
(
87
log_id int identity primary key,--编号
88
log_date datetime default getdate(),--操作时间
89
[user_id] int not null,--操作人信息
90
log_ip varchar(15) not null, --操作人登录IP ,222.222.222.222
91
log_message varchar(500) not null,--操作事件
92
log_isUser bit default 1 --是否是前台用户,1是前台用户,0后台用户
93
)
94
95
--9.短信类型 message_class mc
96
create table mc
97
(
98
mc_id int identity primary key,
99
mc_name varchar(100) not null,--名称
100
)
101
102
--10.短信,后台管理员、前台用户之间 message
103
create table message
104
(
105
m_id int identity primary key,--编号
106
m_from int not null,--发送人编号 ,0为管理员
107
m_to int not null,--接收人编号,0为管理员,-1为所有的用户
108
m_title varchar(200) not null, --标题
109
m_message text not null,--内容
110
m_date datetime default getdate(),--发送时间
111
m_c bit default 0,--是否查看,0未查看,1查看
112
m_from_id int default 0,--0为首发,其它为回复
113
mc_id int not null --短信类型
114
)
115
116
--m_title,m_date,
117
118
--m_from,m_to,m_title,m_message,m_from_id,mc_id
119
120
--11.送货方式 set
121
create table [set]
122
(
123
set_id int identity primary key,--编号
124
set_title varchar(200) not null,--名称
125
set_explain text, -- 说明
126
set_money varchar(10) not null --钱
127
)
128
129
--12.订单表 send
130
create table send
131
(
132
send_id int identity primary key,--编号
133
send_bookMoney float not null,--书籍的价钱
134
set_id int not null,--邮寄的方式
135
set_money varchar(10) not null,--钱
136
set_com varchar(200) ,--收货人公司
137
send_invoice bit default 0,-- 是否需要发票,0不需要,1需要
138
send_ms int default 0 ,--收货人称谓,0先生,1女土/小姐,2保密
139
send_name varchar(100) not null,--收货人姓名
140
send_photo varchar(100) not null,--收货人电话
141
send_mail varchar(100), --收货人Email
142
send_yb varchar(100),-- 收货人邮编
143
send_add varchar(200) not null,--收货人地址
144
send_text text,--备注
145
146
send_time datetime default getdate(),--订单时间
147
148
send_isGet_num varchar(200),--汇款编号
149
send_isGet bit default 0, --是否收到汇款,0未收到,1收到
150
send_isGet_Date datetime,--收到汇款的时间
151
send_isEnt bit default 0, --是否已经电话确认
152
send_isEnt_Date datetime,--收到汇款后确认的时间
153
send_isSet bit default 0 --是否已经发货
154
send_isSet_Date datetime,--发货时间
155
)
156
157
--13.订单明细表 shop
158
create table shop
159
(
160
shop_id int identity primary key,--编号
161
[user_id] int not null,--用户编号
162
book_id int not null,--书籍编号
163
book_num int not null,--书籍数量
164
book_price varchar(10) not null,--卖出时的单价
165
shop_date datetime default getdate(),--购买时间
166
send_id int not null --邮寄编号,与订单表send 中的 send_id关联
167
)
168
169
--14.购物车 bus
170
create table bus
171
(
172
b_id int identity primary key,
173
[user_id] varchar(100) not null,--购物车ID,登录用户为该用户的编号,匿名用户则创始临时的用户编号
174
book_id int not null,--书籍编号
175
book_num int not null,--书籍数量
176
book_price varchar(10) not null,--书籍卖出时的单价
177
shop_date datetime default getdate() --购买时间
178
)
179
180
--15.销售记录表 bookSaleInfo
181
create table bookSaleInfo
182
(
183
sale_id int identity primary key,
184
book_id int not null,--书籍编号
185
book_num int not null,--书籍数量
186
book_price float not null,--单位价格
187
send_id int not null --订单编号
188
)
189
190
--16.收藏夹 Favorites
191
create table Favorites
192
(
193
f_id int identity primary key,--编号
194
[user_id] int not null,--用户编号
195
book_id int not null,--书籍编号
196
)
197
198
--17.搜索关键字 searchs
199
create table search
200
(
201
s_id int identity primary key,--编号
202
s_name varchar(200) not null,--关键字\
203
s_count int default 1 --查找次数
204
)
205
206
--18.评论表 bbs
207
create table bbs
208
(
209
b_id int identity primary key,--编号
210
b_date datetime default getdate(),
211
b_email varchar(50),
212
book_id int not null
213
)
214
215
--19.蜘蛛抓取到的页面内容 rebot
216
create table rebot
217
(
218
book_id int identity primary key,--书籍编号
219
book_name varchar(200) ,--图书名称
220
class_id int not null,--图书类别 与bookClass表对应
221
book_come varchar(200),--出版社
222
book_author varchar(200) ,--作者
223
book_price varchar(10) ,--定价
224
book_price1 varchar(10),--买出时的价钱
225
book_disk varchar(100),--光盘数
226
book_volume varchar(100),--册数
227
book_image varchar(200),--图片路径
228
book_text text, --书籍说明,内容简介
229
book_date datetime default GETDATE(),--添加日期
230
url varchar(100) ,--页面链接
231
[id] int default 0--图书是否删除,0未被审核,-1未通过审核,其它为该书在book表中的编号
232
)
233
234
--22601-4=22597
235
236
book_name,class_id,book_come,book_author,book_price,book_price1,book_disk,book_volume,book_text,url
237
---------------------------------------------------------------------------------
238
-----------视图------------------------------------------------------------------
239
---------------------------------------------------------------------------------
240
--1.书籍信息视图
241
CREATE VIEW bookInfo
242
as
243
SELECT A.*,B.[class_name] FROM [book] AS A,[bookClass] AS B WHERE A.[class_id]=B.[class_id]
244
245
--2.销售信息记录
246
CREATE VIEW sellStat
247
as
248
SELECT
249
C.[book_id],C.[book_name],C.[book_price] as price1,B.[book_price] as price2,B.[book_num],B.[shop_date],A.[send_isSet_Date]
250
FROM
251
[send] AS A,[shop] AS B,[book] AS C
252
WHERE
253
A.[send_isset]=1 AND
254
A.send_id=B.[send_id] AND
255
B.[book_id]=C.[book_id]
256
257
--3.邮寄记录视图
258
CREATE VIEW setStat0
259
AS
260
SELECT
261
A.[set_id],B.[set_title],A.[set_money],A.[send_isSet_Date]
262
FROM
263
[send] AS A,[set] AS B
264
WHERE
265
A.[set_id]=B.[set_id] AND A.[send_isset]=1
266
267
--4.卖出的书视图
268
CREATE VIEW sellBook
269
AS
270
SELECT
271
B.[book_id],B.[book_name],A.[book_price],A.[book_num] ,A.[send_id]
272
FROM
273
[shop] AS A,[book] AS B
274
WHERE A.[book_id]=B.[book_id]
275
276
--5、未删除书籍
277
create view bookView
278
as
279
select * from book where book_isDel=0
280
281
--6、属性书籍视图 bookRSView
282
create view bookRSView
283
as
284
SELECT A.*,B.[ba_id] FROM book AS A,RS AS B WHERE A.[book_id]=B.book_id AND A.book_isDel=0
285
286
--7、购物车详细内容视图 busView
287
create view busView
288
as
289
SELECT A.*,B.[book_name] FROM [bus] AS A,[book] AS B WHERE A.[book_id]=B.[book_id]
290
291
--8、销售成功记录视图 send_suss_view1
292
create view send_suss_view1
293
as
294
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_isSet_Date] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isSet]=1
295
296
--9、收到汇款但没有发货的记录
297
create view send_suss_view2
298
as
299
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_isGet_Date] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isGet]=1
300
301
--10、发送订单但还没有收到汇款(当然没有交易成功)
302
create view send_suss_view3
303
as
304
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_time] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isGet]=0
305
306
--11、所有订单信息 send_suss_view
307
create view send_suss_view
308
as
309
SELECT
310
A.[send_id],
311
A.[send_bookMoney],
312
[Date]=A.send_time,
313
time2=CASE A.[send_isGet] WHEN 0 THEN '未收到汇款' ELSE CONVERT(CHAR,A.[send_isGet_Date],120) END,
314
time3=CASE A.[send_isset] WHEN 0 THEN '未发送书籍' ELSE CONVERT(CHAR,A.[send_isSet_Date],120) END,
315
A.[set_money],
316
A.[send_time],
317
A.[send_isGet],
318
A.[send_isEnt],
319
A.[send_isset]
320
321
FROM [send]AS A,[set] AS B WHERE A.[set_id]=B.[set_id]
322
323
--12、订单详细信息 showSendView
324
create view showSendView
325
as
326
SELECT
327
A.[send_id],
328
A.[set_com],
329
send_invoice=CASE A.[send_invoice] WHEN 0 THEN '不需要' ELSE '需要' END,
330
A.[send_photo],
331
A.[send_name],
332
sex=CASE A.[send_ms] WHEN 0 THEN '先生' WHEN 1 THEN '女土/小姐' ELSE '保密' END,
333
A.[send_mail],
334
A.[send_add],
335
A.[send_yb],
336
A.[send_isGet_num],
337
A.[send_text],
338
B.[set_title],
339
A.[set_money],
340
A.[send_time],
341
A.[send_isGet],
342
A.[send_bookMoney],
343
A.[send_isEnt],
344
A.[send_isset]
345
FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id]
346
347
348
--13、行业图书二级栏目 class_two_View
349
create view class_two_View
350
as
351
SELECT [class_id],[class_name],dbo.fun_getPY(class_name) AS PY FROM [bookClass] WHERE [class_parent]=1
352
353
354
--自定义函数,获取首字母
355
CREATE function fun_getPY(@str nvarchar(4000))
356
returns nvarchar(4000)
357
as
358
begin
359
declare @word nchar(1),@PY nvarchar(4000)
360
set @PY=''
361
362
set @word=left(@str,1)
363
--如果非汉字字符,返回原字符
364
set @PY=(case when unicode(@word) between 19968 and 19968+20901
365
then (select top 1 PY from (
366
select 'A' as PY,N'驁' as word
367
union all select 'B',N'簿'
368
union all select 'C',N'錯'
369
union all select 'D',N'鵽'
370
union all select 'E',N'樲'
371
union all select 'F',N'鰒'
372
union all select 'G',N'腂'
373
union all select 'H',N'夻'
374
union all select 'J',N'攈'
375
union all select 'K',N'穒'
376
union all select 'L',N'鱳'
377
union all select 'M',N'旀'
378
union all select 'N',N'桛'
379
union all select 'O',N'漚'
380
union all select 'P',N'曝'
381
union all select 'Q',N'囕'
382
union all select 'R',N'鶸'
383
union all select 'S',N'蜶'
384
union all select 'T',N'籜'
385
union all select 'W',N'鶩'
386
union all select 'X',N'鑂'
387
union all select 'Y',N'韻'
388
union all select 'Z',N'咗'
389
) T
390
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
391
order by PY ASC) else @word end)
392
393
return @PY
394
end
395
396
397
---------------------------------------------------------------------------------
398
-----------四层体系结构----------------------------------------------------------
399
---------------------------------------------------------------------------------
400
--1.表示层 bookshop
401
--2.业务逻辑层 BLL
402
--3.数据访问层 DAL
403
--4.数据库模型 MOD
404
405
--表示层 USL
406
--表示层包括站点的用户界面元素,以及管理访问者和书店之间的交互的所有逻辑。该层使整个站点充满活力,该层的设计对站点的成败是非常重要的。对本系统而言,其表示层是由网页及其组件组成。
407
408
--业务逻辑层 BLL
409
--负责处理表示层的请求,并根据表示层包含的业务逻辑绐表示层一个返回结果。在表示层发生的所有事件都用调用业务逻辑层。例如:如果访问者进行会员登录,表示层就要调用业务逻辑层告诉表示层“该访问者是不是合法用户”。而业务逻辑罢则需要调用数据层,从数据库中获取其中满足表示层请求的信息。
410
411
--数据访问层 DAL
412
--数据访问层提供了访问数据模型层的基本方法,接收业务逻辑层的请求,把数据模型层中的数据发送绐业务逻辑层。对于这个系统来说,需要存储有关书籍资料、会员、购物车等信息,几乎每个访问者请求最终都会通过数据访问层在数据模型层中提取数据。
413
414
--数据模型层 MOD
415
--运用数据集对数据中的相关的表和视图进行封装。
416
417
--对于这四层结构模型,有一个重要的规则:必须按顺序在各层之间进行数据访问,表示层只允许访问业务逻辑层,不能直接访问数据库。业务逻辑层可以与其他两个层进行通信,处理和协调所有的信息流。
418
--数据库
419
420
--C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
421
422
--d:\windows\system32\inetsrv\data\sDict.txt
423
424
--c:\windows\system32\inetsrv\
425
--data\sDict.txt
426
427
--Cookie
428
--用户编号 book_Cookie_id
429
--用户名称 book_Cookie_name
create database book2
use book3
go4

5
--1.图书类别分类表 bookClass6
create table bookClass7
(8
class_id int identity primary key,--编号9
class_name varchar(100) not null, --名称10
class_parent int default 0--父类11
)12

13
--2.图书信息 book14
create table book15
(16
book_id int identity primary key,--书籍编号17
book_name varchar(200) not null,--图书名称18
class_id int not null,--图书类别 与bookClass表对应19
book_come varchar(200),--出版社20
book_author varchar(200) not null,--作者21
book_price varchar(10) not null,--定价22
book_price1 varchar(10) not null,--买出时的价钱23
book_ISBN varchar(50),--ISBN24
book_time datetime, --出版日期25
book_disk varchar(100),--光盘数26
book_volume varchar(100),--册数27
book_image varchar(200),--图片路径28
book_text text, --书籍说明,内容简介29
book_key varchar(200),--关键字,多个关键字之间用逗号隔开30
book_date datetime default GETDATE(),--添加日期31
book_isDel int default 0--图书是否删除,0正常未被删除,1被删除,从BIT型改为INT型,2通过审核还没有生成静态页面32
)33

34
--book_name,class_id,book_come,book_author,book_price,book_price1,book_ISBN,book_time,book_disk,book_volume,book_image,book_text,book_key35

36
--3.图书属性 book_attribute 推荐 热销 关注37
create table book_attribute38
(39
ba_id int identity primary key,--编号40
ba_name varchar(50) not null,--名称41
)42

43
--4.推荐、热销、关注等表图书表44
create table RS45
(46
id int identity primary key,--编号47
book_id int not null,--书籍编号,与book表中的书籍编号关联48
rs_date datetime default GETDATE(), --日期49
ba_id int not null --属性编号,与book_attribute表关联50
)51

52
--5.书店讯息 new53
create table new54
(55
new_id int identity primary key,--编号56
new_title varchar(200) not null,--标题57
new_content text not null,--内容58
new_date datetime default getdate() --添加时间59
)60

61
--6.用户注册信息 user62
create table [user]63
(64
[user_id] int identity primary key,--编号65
[user_name] varchar(100) not null,--用户名称66
user_pass varchar(32) not null,--密码67
user_mail varchar(100) not null, --邮箱68
user_quest varchar(200),--问题69
user_answer varchar(200),--答案70
user_money float default 0, --存取在本站的金额71
user_receive int default 0 --积分72
)73

74
--7.后台管理员信息 admin75
create table admin76
(77
admin_id int identity primary key,--编号78
admin_name varchar(100) not null,--管理员名称79
admin_pass varchar(32) not null, --密码80
--权限81
admin_class int default 1 --用户类别,0管理员,1普通管理员82
)83

84
--8.操作日志 log85
create table [log]86
(87
log_id int identity primary key,--编号88
log_date datetime default getdate(),--操作时间89
[user_id] int not null,--操作人信息90
log_ip varchar(15) not null, --操作人登录IP ,222.222.222.22291
log_message varchar(500) not null,--操作事件92
log_isUser bit default 1 --是否是前台用户,1是前台用户,0后台用户93
)94

95
--9.短信类型 message_class mc96
create table mc97
(98
mc_id int identity primary key,99
mc_name varchar(100) not null,--名称100
)101

102
--10.短信,后台管理员、前台用户之间 message103
create table message104
(105
m_id int identity primary key,--编号106
m_from int not null,--发送人编号 ,0为管理员107
m_to int not null,--接收人编号,0为管理员,-1为所有的用户108
m_title varchar(200) not null, --标题109
m_message text not null,--内容110
m_date datetime default getdate(),--发送时间111
m_c bit default 0,--是否查看,0未查看,1查看112
m_from_id int default 0,--0为首发,其它为回复113
mc_id int not null --短信类型114
)115

116
--m_title,m_date,117

118
--m_from,m_to,m_title,m_message,m_from_id,mc_id119

120
--11.送货方式 set 121
create table [set]122
(123
set_id int identity primary key,--编号124
set_title varchar(200) not null,--名称125
set_explain text, -- 说明126
set_money varchar(10) not null --钱127
)128

129
--12.订单表 send130
create table send131
(132
send_id int identity primary key,--编号133
send_bookMoney float not null,--书籍的价钱134
set_id int not null,--邮寄的方式135
set_money varchar(10) not null,--钱136
set_com varchar(200) ,--收货人公司137
send_invoice bit default 0,-- 是否需要发票,0不需要,1需要138
send_ms int default 0 ,--收货人称谓,0先生,1女土/小姐,2保密139
send_name varchar(100) not null,--收货人姓名140
send_photo varchar(100) not null,--收货人电话141
send_mail varchar(100), --收货人Email142
send_yb varchar(100),-- 收货人邮编143
send_add varchar(200) not null,--收货人地址144
send_text text,--备注145
146
send_time datetime default getdate(),--订单时间147
148
send_isGet_num varchar(200),--汇款编号149
send_isGet bit default 0, --是否收到汇款,0未收到,1收到150
send_isGet_Date datetime,--收到汇款的时间151
send_isEnt bit default 0, --是否已经电话确认152
send_isEnt_Date datetime,--收到汇款后确认的时间153
send_isSet bit default 0 --是否已经发货154
send_isSet_Date datetime,--发货时间155
)156

157
--13.订单明细表 shop158
create table shop159
(160
shop_id int identity primary key,--编号161
[user_id] int not null,--用户编号162
book_id int not null,--书籍编号163
book_num int not null,--书籍数量164
book_price varchar(10) not null,--卖出时的单价165
shop_date datetime default getdate(),--购买时间166
send_id int not null --邮寄编号,与订单表send 中的 send_id关联167
)168

169
--14.购物车 bus170
create table bus171
(172
b_id int identity primary key,173
[user_id] varchar(100) not null,--购物车ID,登录用户为该用户的编号,匿名用户则创始临时的用户编号174
book_id int not null,--书籍编号175
book_num int not null,--书籍数量176
book_price varchar(10) not null,--书籍卖出时的单价177
shop_date datetime default getdate() --购买时间178
)179

180
--15.销售记录表 bookSaleInfo181
create table bookSaleInfo182
(183
sale_id int identity primary key,184
book_id int not null,--书籍编号185
book_num int not null,--书籍数量186
book_price float not null,--单位价格187
send_id int not null --订单编号188
)189

190
--16.收藏夹 Favorites191
create table Favorites192
(193
f_id int identity primary key,--编号194
[user_id] int not null,--用户编号195
book_id int not null,--书籍编号196
)197

198
--17.搜索关键字 searchs199
create table search200
(201
s_id int identity primary key,--编号202
s_name varchar(200) not null,--关键字\203
s_count int default 1 --查找次数204
)205

206
--18.评论表 bbs207
create table bbs208
(209
b_id int identity primary key,--编号210
b_date datetime default getdate(),211
b_email varchar(50),212
book_id int not null213
)214

215
--19.蜘蛛抓取到的页面内容 rebot216
create table rebot217
(218
book_id int identity primary key,--书籍编号219
book_name varchar(200) ,--图书名称220
class_id int not null,--图书类别 与bookClass表对应221
book_come varchar(200),--出版社222
book_author varchar(200) ,--作者223
book_price varchar(10) ,--定价224
book_price1 varchar(10),--买出时的价钱225
book_disk varchar(100),--光盘数226
book_volume varchar(100),--册数227
book_image varchar(200),--图片路径228
book_text text, --书籍说明,内容简介229
book_date datetime default GETDATE(),--添加日期230
url varchar(100) ,--页面链接231
[id] int default 0--图书是否删除,0未被审核,-1未通过审核,其它为该书在book表中的编号232
)233

234
--22601-4=22597235

236
book_name,class_id,book_come,book_author,book_price,book_price1,book_disk,book_volume,book_text,url237
---------------------------------------------------------------------------------238
-----------视图------------------------------------------------------------------239
---------------------------------------------------------------------------------240
--1.书籍信息视图241
CREATE VIEW bookInfo242
as 243
SELECT A.*,B.[class_name] FROM [book] AS A,[bookClass] AS B WHERE A.[class_id]=B.[class_id]244

245
--2.销售信息记录246
CREATE VIEW sellStat247
as248
SELECT 249
C.[book_id],C.[book_name],C.[book_price] as price1,B.[book_price] as price2,B.[book_num],B.[shop_date],A.[send_isSet_Date] 250
FROM 251
[send] AS A,[shop] AS B,[book] AS C 252
WHERE 253
A.[send_isset]=1 AND 254
A.send_id=B.[send_id] AND 255
B.[book_id]=C.[book_id]256

257
--3.邮寄记录视图258
CREATE VIEW setStat0259
AS260
SELECT 261
A.[set_id],B.[set_title],A.[set_money],A.[send_isSet_Date] 262
FROM 263
[send] AS A,[set] AS B 264
WHERE 265
A.[set_id]=B.[set_id] AND A.[send_isset]=1266

267
--4.卖出的书视图268
CREATE VIEW sellBook269
AS270
SELECT 271
B.[book_id],B.[book_name],A.[book_price],A.[book_num] ,A.[send_id] 272
FROM273
[shop] AS A,[book] AS B 274
WHERE A.[book_id]=B.[book_id]275

276
--5、未删除书籍277
create view bookView278
as 279
select * from book where book_isDel=0280

281
--6、属性书籍视图 bookRSView282
create view bookRSView283
as 284
SELECT A.*,B.[ba_id] FROM book AS A,RS AS B WHERE A.[book_id]=B.book_id AND A.book_isDel=0285

286
--7、购物车详细内容视图 busView287
create view busView288
as289
SELECT A.*,B.[book_name] FROM [bus] AS A,[book] AS B WHERE A.[book_id]=B.[book_id]290

291
--8、销售成功记录视图 send_suss_view1292
create view send_suss_view1293
as294
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_isSet_Date] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isSet]=1295

296
--9、收到汇款但没有发货的记录297
create view send_suss_view2298
as299
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_isGet_Date] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isGet]=1300

301
--10、发送订单但还没有收到汇款(当然没有交易成功)302
create view send_suss_view3303
as304
SELECT A.send_id,A.[send_bookMoney],B.[set_title],A.[set_money],A.[send_time] as [Date] FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id] AND A.[send_isGet]=0305

306
--11、所有订单信息 send_suss_view307
create view send_suss_view308
as309
SELECT 310
A.[send_id],311
A.[send_bookMoney],312
[Date]=A.send_time,313
time2=CASE A.[send_isGet] WHEN 0 THEN '未收到汇款' ELSE CONVERT(CHAR,A.[send_isGet_Date],120) END,314
time3=CASE A.[send_isset] WHEN 0 THEN '未发送书籍' ELSE CONVERT(CHAR,A.[send_isSet_Date],120) END,315
A.[set_money],316
A.[send_time],317
A.[send_isGet],318
A.[send_isEnt],319
A.[send_isset]320
321
FROM [send]AS A,[set] AS B WHERE A.[set_id]=B.[set_id]322

323
--12、订单详细信息 showSendView324
create view showSendView325
as326
SELECT 327
A.[send_id],328
A.[set_com],329
send_invoice=CASE A.[send_invoice] WHEN 0 THEN '不需要' ELSE '需要' END,330
A.[send_photo],331
A.[send_name],332
sex=CASE A.[send_ms] WHEN 0 THEN '先生' WHEN 1 THEN '女土/小姐' ELSE '保密' END,333
A.[send_mail],334
A.[send_add],335
A.[send_yb],336
A.[send_isGet_num],337
A.[send_text],338
B.[set_title],339
A.[set_money],340
A.[send_time],341
A.[send_isGet],342
A.[send_bookMoney],343
A.[send_isEnt],344
A.[send_isset]345
FROM [send] AS A,[set] AS B WHERE A.[set_id]=B.[set_id]346

347

348
--13、行业图书二级栏目 class_two_View349
create view class_two_View350
as351
SELECT [class_id],[class_name],dbo.fun_getPY(class_name) AS PY FROM [bookClass] WHERE [class_parent]=1352

353

354
--自定义函数,获取首字母355
CREATE function fun_getPY(@str nvarchar(4000))356
returns nvarchar(4000)357
as358
begin359
declare @word nchar(1),@PY nvarchar(4000)360
set @PY=''361

362
set @word=left(@str,1)363
--如果非汉字字符,返回原字符364
set @PY=(case when unicode(@word) between 19968 and 19968+20901365
then (select top 1 PY from (366
select 'A' as PY,N'驁' as word367
union all select 'B',N'簿'368
union all select 'C',N'錯'369
union all select 'D',N'鵽'370
union all select 'E',N'樲'371
union all select 'F',N'鰒'372
union all select 'G',N'腂'373
union all select 'H',N'夻'374
union all select 'J',N'攈'375
union all select 'K',N'穒'376
union all select 'L',N'鱳'377
union all select 'M',N'旀'378
union all select 'N',N'桛'379
union all select 'O',N'漚'380
union all select 'P',N'曝'381
union all select 'Q',N'囕'382
union all select 'R',N'鶸'383
union all select 'S',N'蜶'384
union all select 'T',N'籜'385
union all select 'W',N'鶩'386
union all select 'X',N'鑂'387
union all select 'Y',N'韻'388
union all select 'Z',N'咗'389
) T 390
where word>=@word collate Chinese_PRC_CS_AS_KS_WS 391
order by PY ASC) else @word end)392

393
return @PY394
end395

396

397
---------------------------------------------------------------------------------398
-----------四层体系结构----------------------------------------------------------399
---------------------------------------------------------------------------------400
--1.表示层 bookshop401
--2.业务逻辑层 BLL402
--3.数据访问层 DAL403
--4.数据库模型 MOD404

405
--表示层 USL406
--表示层包括站点的用户界面元素,以及管理访问者和书店之间的交互的所有逻辑。该层使整个站点充满活力,该层的设计对站点的成败是非常重要的。对本系统而言,其表示层是由网页及其组件组成。407
408
--业务逻辑层 BLL409
--负责处理表示层的请求,并根据表示层包含的业务逻辑绐表示层一个返回结果。在表示层发生的所有事件都用调用业务逻辑层。例如:如果访问者进行会员登录,表示层就要调用业务逻辑层告诉表示层“该访问者是不是合法用户”。而业务逻辑罢则需要调用数据层,从数据库中获取其中满足表示层请求的信息。410
411
--数据访问层 DAL412
--数据访问层提供了访问数据模型层的基本方法,接收业务逻辑层的请求,把数据模型层中的数据发送绐业务逻辑层。对于这个系统来说,需要存储有关书籍资料、会员、购物车等信息,几乎每个访问者请求最终都会通过数据访问层在数据模型层中提取数据。413
414
--数据模型层 MOD415
--运用数据集对数据中的相关的表和视图进行封装。416
417
--对于这四层结构模型,有一个重要的规则:必须按顺序在各层之间进行数据访问,表示层只允许访问业务逻辑层,不能直接访问数据库。业务逻辑层可以与其他两个层进行通信,处理和协调所有的信息流。418
--数据库419

420
--C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727421

422
--d:\windows\system32\inetsrv\data\sDict.txt423

424
--c:\windows\system32\inetsrv\425
--data\sDict.txt426

427
--Cookie428
--用户编号 book_Cookie_id429
--用户名称 book_Cookie_name
浙公网安备 33010602011771号