Вы находитесь на странице: 1из 6

/

*================================================
==============*/
/* DBMS name:
/* Created on:

Microsoft SQL Server 2000


25/06/2015 15:48:14

*/
*/

/
*================================================
==============*/

if exists (select 1
from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type =
'F')
where r.fkeyid = object_id('SERVIS_AWAL') and o.name =
'FK_SERVIS_A_MELAKUKAN_ID_PELAN')
alter table SERVIS_AWAL
drop constraint FK_SERVIS_A_MELAKUKAN_ID_PELAN
go

if exists (select 1
from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type =
'F')
where r.fkeyid = object_id('SERVIS_SELESAI') and o.name =
'FK_SERVIS_S_DATA_TERS_ID_PELAN')
alter table SERVIS_SELESAI
drop constraint FK_SERVIS_S_DATA_TERS_ID_PELAN
go

if exists (select 1
from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type =
'F')

where r.fkeyid = object_id('SERVIS_SELESAI') and o.name =


'FK_SERVIS_S_TERSELESA_SERVIS_A')
alter table SERVIS_SELESAI
drop constraint FK_SERVIS_S_TERSELESA_SERVIS_A
go

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

if exists (select 1
from sysindexes
where id

= object_id('SERVIS_AWAL')

and name = 'MELAKUKAN_SERVIS_FK'


and indid > 0
and indid < 255)
drop index SERVIS_AWAL.MELAKUKAN_SERVIS_FK
go

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

if exists (select 1
from sysindexes
where id

= object_id('SERVIS_SELESAI')

and name = 'DATA_TERSELESAIKAN_FK'


and indid > 0
and indid < 255)
drop index SERVIS_SELESAI.DATA_TERSELESAIKAN_FK
go

if exists (select 1
from sysindexes
where id

= object_id('SERVIS_SELESAI')

and name = 'TERSELESAIKAN_FK'


and indid > 0
and indid < 255)
drop index SERVIS_SELESAI.TERSELESAIKAN_FK
go

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

/
*================================================
==============*/
/* Table: ID_PELANGGAN

*/

/
*================================================
==============*/
create table ID_PELANGGAN (
ID_PELANGGAN

varchar(20)

NAMA_PELANGGAN

varchar(55)

not null,
null,

constraint PK_ID_PELANGGAN primary key nonclustered (ID_PELANGGAN)


)
go

/
*================================================
==============*/
/* Table: SERVIS_AWAL

*/

/
*================================================
==============*/
create table SERVIS_AWAL (
JENIS_SERVIS
ID_PELANGGAN
TANGGAL_MASUK

varchar(100)
varchar(20)
datetime

not null,
not null,
not null,

constraint PK_SERVIS_AWAL primary key nonclustered (JENIS_SERVIS)


)
go

/
*================================================
==============*/
/* Index: MELAKUKAN_SERVIS_FK

*/

/
*================================================
==============*/

create index MELAKUKAN_SERVIS_FK on SERVIS_AWAL (


ID_PELANGGAN ASC
)
go

/
*================================================
==============*/
/* Table: SERVIS_SELESAI

*/

/
*================================================
==============*/
create table SERVIS_SELESAI (
ID_PELANGGAN
JENIS_SERVIS
TANGGAL_SELESAI
BIAYA_SERVIS

varchar(20)
varchar(100)
datetime
money

not null,
not null,
null,
null

)
go

/
*================================================
==============*/
/* Index: TERSELESAIKAN_FK

*/

/
*================================================
==============*/
create index TERSELESAIKAN_FK on SERVIS_SELESAI (
JENIS_SERVIS ASC
)
go

/
*================================================
==============*/
/* Index: DATA_TERSELESAIKAN_FK

*/

/
*================================================
==============*/
create index DATA_TERSELESAIKAN_FK on SERVIS_SELESAI (
ID_PELANGGAN ASC
)
go

alter table SERVIS_AWAL


add constraint FK_SERVIS_A_MELAKUKAN_ID_PELAN foreign key
(ID_PELANGGAN)
references ID_PELANGGAN (ID_PELANGGAN)
go

alter table SERVIS_SELESAI


add constraint FK_SERVIS_S_DATA_TERS_ID_PELAN foreign key
(ID_PELANGGAN)
references ID_PELANGGAN (ID_PELANGGAN)
go

alter table SERVIS_SELESAI


add constraint FK_SERVIS_S_TERSELESA_SERVIS_A foreign key (JENIS_SERVIS)
references SERVIS_AWAL (JENIS_SERVIS)
go

Вам также может понравиться