상세 컨텐츠

본문 제목

DataBase생성

청강컴정/09DataBase중간고사

by luckey 2009. 4. 14. 19:00

본문




use master
go
if DB_ID('cafe_manage') IS NOT NULL
DROP DATABASE cafe_manage
go
CREATE DATABASE cafe_manage
go
use cafe_manage
go

create table Member
(
    sn int identity(1,1) primary key,
    name nvarchar(5) not null,
    id varchar(20) not null,
    m_join_date datetime default getdate(),
    sex bit default(0),
    birthday char(10)
)

create table Category
(
    cate_id int identity(1,1) primary key,
    cate_name nvarchar(20) not null
)

create table Cafe
(
    sn int identity(1,1) primary key,
    name nvarchar(50) not null,
    make_date datetime default getdate(),
    fk_cate int foreign key references Category (cate_id)
)

create table Member_join
(
    fk_member int foreign key references Member(sn),
    fk_cafe int foreign key references Cafe(sn),
    join_date datetime default getdate(),
    visit_count int default(0),
)

create table Member_visit
(
    fk_member int foreign key references Member(sn),
    fk_cafe int foreign key references Cafe(sn),
    visit_count_day int default(0),
    visit_date_day char(10)
)

관련글 더보기

댓글 영역