Selasa, 15 Oktober 2013

Tugas Inventaris CDM,PDM & SCRIPT

CONCEPTUAL DATA MODEL MANUAL



PHYSICAL DATA MODEL

SRIPT

/*==============================================================*/
/* DBMS name:      Sybase AS Enterprise 15.0                    */
/* Created on:     15/10/2013 22:23:29                          */
/*==============================================================*/


if exists (select 1 
            from  sysobjects c 
            join  sysconstraints s on (s.constrid = c.id and s.tableid = object_id('PETUGAS'))
            where name = 'FK_PETUGAS_RELATIONS_TABEL_RU' and type = 'RI')
   alter table PETUGAS
      drop constraint FK_PETUGAS_RELATIONS_TABEL_RU
go

if exists (select 1 
            from  sysobjects c 
            join  sysconstraints s on (s.constrid = c.id and s.tableid = object_id('PETUGAS'))
            where name = 'FK_PETUGAS_RELATIONS_TABEL_BA' and type = 'RI')
   alter table PETUGAS
      drop constraint FK_PETUGAS_RELATIONS_TABEL_BA
go

if exists (select 1 
            from  sysobjects c 
            join  sysconstraints s on (s.constrid = c.id and s.tableid = object_id('PETUGAS'))
            where name = 'FK_PETUGAS_RELATIONS_TABEL_GU' and type = 'RI')
   alter table PETUGAS
      drop constraint FK_PETUGAS_RELATIONS_TABEL_GU
go

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

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

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

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

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

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

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

/*==============================================================*/
/* Table: PETUGAS                                               */
/*==============================================================*/
create table PETUGAS (
   ID_PETUGAS           int                            not null,
   ID_BARANG            int                            null,
   ID_GUDANG            int                            null,
   ID_RUANGAN           int                            null,
   NAMA_PETUGAS         char(50)                       null,
   JABATAN              char(50)                       null,
   ALAMAT               char(50)                       null,
   NO_HP                int                            null,
   constraint PK_PETUGAS primary key nonclustered (ID_PETUGAS)
)
go

/*==============================================================*/
/* Index: RELATIONSHIP_1_FK                                     */
/*==============================================================*/
create index RELATIONSHIP_1_FK on PETUGAS (
ID_RUANGAN ASC
)
go

/*==============================================================*/
/* Index: RELATIONSHIP_2_FK                                     */
/*==============================================================*/
create index RELATIONSHIP_2_FK on PETUGAS (
ID_BARANG ASC
)
go

/*==============================================================*/
/* Index: RELATIONSHIP_3_FK                                     */
/*==============================================================*/
create index RELATIONSHIP_3_FK on PETUGAS (
ID_GUDANG ASC
)
go

/*==============================================================*/
/* Table: TABEL_BARANG                                          */
/*==============================================================*/
create table TABEL_BARANG (
   ID_BARANG            int                            not null,
   NAMA_BARANG          char(50)                       null,
   JENIS_BARANG         char(50)                       null,
   constraint PK_TABEL_BARANG primary key nonclustered (ID_BARANG)
)
go

/*==============================================================*/
/* Table: TABEL_GUDANG                                          */
/*==============================================================*/
create table TABEL_GUDANG (
   ID_GUDANG            int                            not null,
   NAMA_GUDANG          char(50)                       null,
   JENIS_GUDANG         char(50)                       null,
   constraint PK_TABEL_GUDANG primary key nonclustered (ID_GUDANG)
)
go

/*==============================================================*/
/* Table: TABEL_RUANGAN                                         */
/*==============================================================*/
create table TABEL_RUANGAN (
   ID_RUANGAN           int                            not null,
   NAMA_RUANGAN         char(50)                       null,
   JENIS_RUANGAN        char(50)                       null,
   constraint PK_TABEL_RUANGAN primary key nonclustered (ID_RUANGAN)
)
go

alter table PETUGAS
   add constraint FK_PETUGAS_RELATIONS_TABEL_RU foreign key (ID_RUANGAN)
      references TABEL_RUANGAN (ID_RUANGAN)
go

alter table PETUGAS
   add constraint FK_PETUGAS_RELATIONS_TABEL_BA foreign key (ID_BARANG)
      references TABEL_BARANG (ID_BARANG)
go

alter table PETUGAS
   add constraint FK_PETUGAS_RELATIONS_TABEL_GU foreign key (ID_GUDANG)
      references TABEL_GUDANG (ID_GUDANG)
go




Tidak ada komentar:

Posting Komentar