Commit b47b8b07 by evi fanny dear

Database Stock control

parent 85f9577b
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_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 Dim_Gudang (
[ID_Gudang] [int] not null,
[Nama_Gudang] [varchar] not null,
[Alamat_Gudang] [varchar] not null,
PRIMARY KEY CLUSTERED
(
[ID_Gudang] 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_Stock_Control](
[ID_Waktu] [int] NOT NULL,
[ID_Barang] [int] NOT NULL,
[ID_Gudang] [int] NOT NULL,
[Jlh_Barang_Masuk] [int] NULL,
[Jlh_Barang_Keluar] [int] NULL,
[Jlh_Barang_Sisa] [int] NULL,
PRIMARY KEY CLUSTERED
(
[ID_Waktu] ASC,
[ID_Barang] ASC,
[ID_Gudang] 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_Stock_Control] WITH CHECK ADD CONSTRAINT [FK_Dim_Gudang_ID_Gudang] FOREIGN KEY([ID_Gudang])
REFERENCES [dbo].[Dim_Gudang] ([ID_Gudang])
GO
ALTER TABLE [dbo].[Fact_Stock_Control] CHECK CONSTRAINT [FK_Dim_Gudang_ID_Gudang]
GO
ALTER TABLE [dbo].[Fact_Stock_Control] WITH CHECK ADD CONSTRAINT [FK_Dim_Waktu_ID_Waktu] FOREIGN KEY([ID_Waktu])
REFERENCES [dbo].[Dim_Waktu] ([ID_Waktu])
GO
ALTER TABLE [dbo].[Fact_Stock_Control] CHECK CONSTRAINT [FK_Dim_Waktu_ID_Waktu]
GO
ALTER TABLE [dbo].[Fact_Stock_Control] WITH CHECK ADD CONSTRAINT [FK_Dim_Barang_ID_Barang] FOREIGN KEY([ID_Barang])
REFERENCES [dbo].[Dim_Barang] ([ID_Barang])
GO
ALTER TABLE [dbo].[Fact_Stock_Control] CHECK CONSTRAINT [FK_Dim_Barang_ID_Barang]
GO
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment