Phân tích mô hình quảng cáo sách Quanca10

Script

Code:

if exists (select 1
            from  sysobjects
          where  id = object_id('NHA_XUAT_BAN')
            and  type = 'U')
  drop table NHA_XUAT_BAN
go

if exists (select 1
            from  sysobjects
          where  id = object_id('PHAN_LOAI_SACH')
            and  type = 'U')
  drop table PHAN_LOAI_SACH
go

if exists (select 1
            from  sysindexes
          where  id    = object_id('SACH')
            and  name  = 'CO_PHAN_LOAI_FK'
            and  indid > 0
            and  indid < 255)
  drop index SACH.CO_PHAN_LOAI_FK
go

if exists (select 1
            from  sysobjects
          where  id = object_id('SACH')
            and  type = 'U')
  drop table SACH
go

/*==============================================================*/
/* Table: NHA_XUAT_BAN                                          */
/*==============================================================*/
create table NHA_XUAT_BAN (
  MANXB                int                  not null,
  TENNXB              nvarchar(300)        null,
  constraint PK_NHA_XUAT_BAN primary key nonclustered (MANXB)
)
go

/*==============================================================*/
/* Table: PHAN_LOAI_SACH                                        */
/*==============================================================*/
create table PHAN_LOAI_SACH (
  MALOAI              int                  not null,
  TENLOAI              nvarchar(300)        null,
  constraint PK_PHAN_LOAI_SACH primary key nonclustered (MALOAI)
)
go

/*==============================================================*/
/* Table: SACH                                                  */
/*==============================================================*/
create table SACH (
  MASACH              varchar(20)          not null,
  MANXB                int                  null,
  MALOAI              int                  null,
  TENSACH              nvarchar(400)        null,
  GIATIEN              int                  null,
  HINHANH              varchar(200)        null,
  GIOITHIEU            nvarchar(MAX)        null,
  constraint PK_SACH primary key nonclustered (MASACH)
)
go

/*==============================================================*/
/* Index: CO_PHAN_LOAI_FK                                      */
/*==============================================================*/
create index CO_PHAN_LOAI_FK on SACH (
MALOAI ASC
)
go