Create a BBS database and create a table

1. Create a new database BBS (the initial size of the main data file: 3MB, the maximum size is unlimited, the file increment: 1MB; the initial size of the log file is 1MB, the maximum size is 10MB, and the file increment is 20%)

2. Create a section table and a post table in the database

Section table (section number [primary key, self-increment], section name)
post table (post number [primary key, self-increment], title [not empty], content, publication time, section number [foreign key])

create database BBS
on primary
(
	name='BBS',
	filename='D:\BBS.mdf',
	size=3MB,
	maxsize=unlimited,
	filegrowth=1MB
)
log on
(
	name='BBS_log',
	filename='D:\BBS_log.ldf',
	size=1MB,
	maxsize=10MB,
	filegrowth=20%
)

use BBS
create table section
(
	secId int primary key identity(1,1),
	secname varchar(20) not null
)
create table card
(
	caId int primary key identity(1,1),
	caname varchar(20) not null,
	content varchar(500)not null,
	publishtime datetime,
	secId int foreign key references section(secId)
)

 

Guess you like

Origin blog.csdn.net/weixin_48135624/article/details/115211450