1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
CREATE TABLE Dim_Barang (
[ID_Barang] [int] not null,
[Nama_Barang] [varchar] not null,
[Kategori_Barang] [varchar] not null,
[Brand] [varchar] not null,
[Harga_Jual_Barang] [money] not null,
[Harga_Beli_Barang] [money] not null,
[Waktu_Kadaluarsa] [timestamp] not null,
PRIMARY KEY CLUSTERED
(
[ID_Barang] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Kategori (
[ID_Kategori] [int] not null,
[Kategori] [varchar] not null,
[Satuan_Barang] [varchar] not null,
PRIMARY KEY CLUSTERED
(
[ID_Kategori] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Satuan (
[ID_Satuan] [int] not null,
[Nama_Satuan] [varchar] not null,
[Harga_Jual_Persatuan] [money] not null,
[Harga_Beli_Persatuan] [money] not null,
[Waktu_Kadaluarsa] [timestamp] not null,
PRIMARY KEY CLUSTERED
(
[ID_Satuan] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Pembayaran (
[ID_Pembayaran] [int] not null,
[Metode_Pembayaran] [varchar] not null,
PRIMARY KEY CLUSTERED
(
[ID_Pembayaran] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Pelanggan (
[ID_Pelanggan] [int] not null,
[Nama_Pelanggan] [varchar] not null,
[Alamat_Pelanggan] [varchar] not null,
[No_Telp_Pelanggan] [int] not null,
PRIMARY KEY CLUSTERED
(
[ID_Pelanggan] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Waktu (
[ID_Waktu] [int] not null,
[Tahun] [timestamp] not null,
[Bulan] [int] not null,
[Tanggal] [date] not null,
PRIMARY KEY CLUSTERED
(
[ID_Waktu] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Tahun (
[ID_Tahun] [int] not null,
[Tahun] [timestamp] not null,
[Bulan] [int] not null,
PRIMARY KEY CLUSTERED
(
[ID_Tahun] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE Dim_Bulan (
[ID_Bulan] [int] not null,
[Bulan] [int] not null,
PRIMARY KEY CLUSTERED
(
[ID_Bulan] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
GO
CREATE TABLE [dbo].[Fact_Penjualan](
[ID_Waktu] [int] NOT NULL,
[ID_Barang] [int] NOT NULL,
[ID_Pelanggan] [int] NOT NULL,
[ID_Pembayaran] [int] NOT NULL,
[Harga_Satuan] [money] NULL,
[PPN_Persen] [decimal] NULL,
[PPN_Rupiah] [decimal] NULL,
[Jlh_Barang_Jual] [int] NULL,
[Jlh_Barang_Bayar] [int] NULL,
[Jlh_Barang_Sebelum_Pajak] [int] NULL,
[Jlh_Barang_Setelah_Pajak] [int] NULL,
PRIMARY KEY CLUSTERED
(
[ID_Waktu] ASC,
[ID_Barang] ASC,
[ID_Pembayaran] ASC,
[ID_Pelanggan] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Fact_Penjualan] WITH CHECK ADD CONSTRAINT [FK_Dim_Barang_ID_Barang] FOREIGN KEY([ID_Barang])
REFERENCES [dbo].[Dim_Barang] ([ID_Barang])
GO
ALTER TABLE [dbo].[Fact_Penjualan] CHECK CONSTRAINT [FK_Dim_Barang_ID_Barang]
GO
ALTER TABLE [dbo].[Fact_Penjualan] WITH CHECK ADD CONSTRAINT [FK_Dim_Pelanggan_ID_Pelanggan] FOREIGN KEY([ID_Pelanggan])
REFERENCES [dbo].[Dim_Pelanggan] ([ID_Pelanggan])
GO
ALTER TABLE [dbo].[Fact_Penjualan] CHECK CONSTRAINT [FK_Dim_Pelanggan_ID_Pelanggan]
GO
ALTER TABLE [dbo].[Fact_Penjualan] WITH CHECK ADD CONSTRAINT [FK_Dim_Pembayaran_ID_Pembayaran] FOREIGN KEY([ID_Pembayaran])
REFERENCES [dbo].[Dim_Pembayaran] ([ID_Pembayaran])
GO
ALTER TABLE [dbo].[Fact_Penjualan] CHECK CONSTRAINT [FK_Dim_Waktu_ID_Waktu]
GO
ALTER TABLE [dbo].[Fact_Penjualan] WITH CHECK ADD CONSTRAINT [FK_Dim_Waktu_ID_Waktu] FOREIGN KEY([ID_Waktu])
REFERENCES [dbo].[Dim_Waktu] ([ID_Waktu])
GO
ALTER TABLE [dbo].[Fact_Penjualan] CHECK CONSTRAINT [FK_Dim_Waktu_ID_Waktu]
GO