Script olarak verilen bir veritabanının oluşturulması

Merhaba Arkadaşlar, Query olarak verilen basit bir teknik servis veritabanı nasıl oluştururuz.
 
1- Yeni bir veritabanı oluşturuyoruz.

2- İsim veriyoruz. (TSDB adında) ve Ok tuşuna basıyoruz.

3- Oluşturduğumuz TSDB adlı veritabanına sağ tıklayıp yeni bir Query açıyoruz

4- Açılan Query e aşağıdaki kodları yapıştırıp menüde bulunan execute tuşuna basıyoruz.



USE [TSDB]

GO

/****** Object:  Table [dbo].[Islem]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Islem](

[islemID] [int] IDENTITY(1,1) NOT NULL,

[kayitID] [int] NULL,

[islemTurID] [int] NULL,

[personelID] [int] NULL,

[aciklama] [nvarchar](max) NULL,

[islemTarihi] [smalldatetime] NULL,

[ucret] [money] NULL,

 CONSTRAINT [PK_Islem] PRIMARY KEY CLUSTERED 

(

[islemID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

/****** Object:  Table [dbo].[IslemTur]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[IslemTur](

[islemTurID] [int] NOT NULL,

[ad] [nvarchar](50) NULL,

[ucret] [money] NULL,

 CONSTRAINT [PK_IslemTur] PRIMARY KEY CLUSTERED 

(

[islemTurID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

/****** Object:  Table [dbo].[Kayit]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Kayit](

[kayitID] [int] IDENTITY(1,1) NOT NULL,

[musteriID] [int] NULL,

[personelID] [int] NULL,

[markaID] [int] NULL,

[ad] [nvarchar](50) NULL,

[problem] [nvarchar](500) NULL,

[alisTarihi] [smalldatetime] NULL,

[teslimTarihi] [smalldatetime] NULL,

[garantiliMi] [bit] NULL,

[tutar] [money] NULL,

[aciklama] [nvarchar](500) NULL,

[durum] [nvarchar](50) NULL,

 CONSTRAINT [PK_Kayit] PRIMARY KEY CLUSTERED 

(

[kayitID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

/****** Object:  Table [dbo].[Marka]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Marka](

[markaID] [int] IDENTITY(1,1) NOT NULL,

[ad] [nchar](10) NULL,

 CONSTRAINT [PK_Marka] PRIMARY KEY CLUSTERED 

(

[markaID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

/****** Object:  Table [dbo].[Musteri]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Musteri](

[musteriID] [int] IDENTITY(1,1) NOT NULL,

[ad] [nvarchar](50) NULL,

[soyad] [nvarchar](50) NULL,

[adres] [nvarchar](max) NULL,

[telefon] [nvarchar](20) NULL,

[kayitTarihi] [smalldatetime] NULL,

 CONSTRAINT [PK_Musteri] PRIMARY KEY CLUSTERED 

(

[musteriID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

/****** Object:  Table [dbo].[Personel]    Script Date: 21.12.2021 10:52:21 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Personel](

[personelID] [int] IDENTITY(1,1) NOT NULL,

[ad] [nvarchar](50) NULL,

[soyad] [nvarchar](50) NULL,

[eposta] [nvarchar](50) NULL,

[sifre] [nvarchar](50) NULL,

 CONSTRAINT [PK_Personel] PRIMARY KEY CLUSTERED 

(

[personelID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Islem]  WITH CHECK ADD  CONSTRAINT [FK_Islem_IslemTur] FOREIGN KEY([islemTurID])

REFERENCES [dbo].[IslemTur] ([islemTurID])

GO

ALTER TABLE [dbo].[Islem] CHECK CONSTRAINT [FK_Islem_IslemTur]

GO

ALTER TABLE [dbo].[Islem]  WITH CHECK ADD  CONSTRAINT [FK_Islem_Kayit] FOREIGN KEY([kayitID])

REFERENCES [dbo].[Kayit] ([kayitID])

GO

ALTER TABLE [dbo].[Islem] CHECK CONSTRAINT [FK_Islem_Kayit]

GO

ALTER TABLE [dbo].[Islem]  WITH CHECK ADD  CONSTRAINT [FK_Islem_Personel] FOREIGN KEY([personelID])

REFERENCES [dbo].[Personel] ([personelID])

GO

ALTER TABLE [dbo].[Islem] CHECK CONSTRAINT [FK_Islem_Personel]

GO

ALTER TABLE [dbo].[Kayit]  WITH CHECK ADD  CONSTRAINT [FK_Kayit_Marka] FOREIGN KEY([markaID])

REFERENCES [dbo].[Marka] ([markaID])

GO

ALTER TABLE [dbo].[Kayit] CHECK CONSTRAINT [FK_Kayit_Marka]

GO

ALTER TABLE [dbo].[Kayit]  WITH CHECK ADD  CONSTRAINT [FK_Kayit_Musteri] FOREIGN KEY([musteriID])

REFERENCES [dbo].[Musteri] ([musteriID])

GO

ALTER TABLE [dbo].[Kayit] CHECK CONSTRAINT [FK_Kayit_Musteri]

GO

ALTER TABLE [dbo].[Kayit]  WITH CHECK ADD  CONSTRAINT [FK_Kayit_Personel] FOREIGN KEY([personelID])

REFERENCES [dbo].[Personel] ([personelID])

GO

ALTER TABLE [dbo].[Kayit] CHECK CONSTRAINT [FK_Kayit_Personel]

GO