论坛网站数据库 [英] Database for Forum Website

查看:88
本文介绍了论坛网站数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在为论坛设计一个网站,类似于The Code Project ...我想知道,我应该使用哪个数据库(例如xml,sql)来存储问题和答案?

Hi all,

I''m designing a website for Forum, similar to The Code Project... I wanted to know , what database(like xml, sql) shall i use to store the question and answers?

推荐答案

用于论坛数据库的脚本

script for forum database

Create table [dbo].[Replies]
(
	[id] Numeric(10,0) Identity NOT NULL,
	[posts_id] Numeric(10,0) NOT NULL,
	[replied_by] Integer NOT NULL,
	[reply] Varchar(5000) NOT NULL,
	[replying_time] Datetime NOT NULL,
Constraint [pk_Replies] Primary Key ([id])
) 
go

Create table [dbo].[Video]
(
	[id] Numeric(10,0) Identity NOT NULL,
	[topic] Char(25) NOT NULL,
	[language] Char(20) NOT NULL,
	[member_id] Integer NOT NULL,
	[title] Char(25) NOT NULL,
	[file_name] Varchar(100) NOT NULL,
	[uploading_time] Datetime NOT NULL,
Constraint [pk_Video] Primary Key ([id])
) 
go

Create table [dbo].[Member]
(
	[id] Integer Identity NOT NULL,
	[first_name] Char(20) NULL,
	[last_name] Char(20) NULL,
	[username] Char(15) NOT NULL, Constraint [UQ__member__77BFCB91] UNIQUE ([username]),
	[password] Char(30) NOT NULL,
	[password_key] Char(30) NOT NULL,
	[date_of_birth] Datetime NOT NULL,
	[sex] Char(1) NULL Constraint [CK__member__sex__78B3EFCA] Check (([sex] = 'M' or [sex] = 'F') ),
	[email_address] Varchar(100) NOT NULL,
	[country] Char(25) NULL,
	[referred_by] Integer NOT NULL,
	[is_date_of_birth_private] Char(1) NOT NULL,
	[receive_email] Char(1) NOT NULL,
	[hint_question] Varchar(100) NULL,
	[hint_answer] Char(20) NULL,
	[active_status] Char(1) NOT NULL,
Constraint [pk_member] Primary Key ([id])
) 
go

Create table [dbo].[Activation]
(
	[username] Char(15) NOT NULL,
	[activation_id] Char(50) NOT NULL,
Constraint [pk_Activation] Primary Key ([username])
) 
go

Create table [dbo].[posts]
(
	[id] Numeric(10,0) Identity NOT NULL,
	[posting_time] Datetime NOT NULL,
	[member_id] Integer NOT NULL,
	[topic] Char(20) NOT NULL,
	[question] Varchar(300) NOT NULL,
Constraint [pk_posts] Primary Key ([id])
) 
go

Create table [dbo].[Music]
(
	[id] Numeric(10,0) Identity NOT NULL,
	[topic] Char(25) NOT NULL,
	[language] Char(20) NOT NULL,
	[member_id] Integer NOT NULL,
	[title] Char(25) NOT NULL,
	[category] Char(15) NOT NULL,
	[singers] Varchar(60) NULL,
	[composer] Varchar(60) NULL,
	[file_name] Varchar(100) NOT NULL,
	[uploading_time] Datetime NOT NULL,
Constraint [pk_Video] Primary Key ([id])
) 
go


Alter table [dbo].[Activation] add  foreign key([username]) references [dbo].[Member] ([username])  on update no action on delete no action 
go
Alter table [dbo].[posts] add  foreign key([member_id]) references [dbo].[Member] ([id])  on update no action on delete no action 
go
Alter table [dbo].[Replies] add  foreign key([replied_by]) references [dbo].[Member] ([id])  on update no action on delete no action 
go
Alter table [dbo].[Video] add  foreign key([member_id]) references [dbo].[Member] ([id])  on update no action on delete no action 
go
Alter table [dbo].[Music] add  foreign key([member_id]) references [dbo].[Member] ([id])  on update no action on delete no action 
go
Alter table [dbo].[Replies] add  foreign key([posts_id]) references [dbo].[posts] ([id])  on update no action on delete no action 
go


Set quoted_identifier on
go


CREATE PROCEDURE [dbo].UpdateActiveStatus
(
	@active_status char(1),
	@Original_id int
)
AS
	SET NOCOUNT OFF;
UPDATE [dbo].[member] SET [active_status] = @active_status WHERE (([id] = @Original_id))
go
Set quoted_identifier off
go
/* Roles permissions */
/* Users permissions */


这篇关于论坛网站数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆