
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KIMLIKKARTFOTO]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[KIMLIKKARTFOTO](
	[KIMLIKKARTFOTOID] [int] NOT NULL,
	[HKIMLIKID] [int] NOT NULL,
	[TARIH] [datetime] NOT NULL,
	[ACIKLAMA] [nvarchar](200) NULL,
	[ADRES] [nvarchar](200) NOT NULL,
	[DOSYA] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_KIMLIKKARTFOTO] PRIMARY KEY CLUSTERED 
(
	[KIMLIKKARTFOTOID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_KIMLIKKARTFOTO_HKIMLIK]') AND parent_object_id = OBJECT_ID(N'[dbo].[KIMLIKKARTFOTO]'))
ALTER TABLE [dbo].[KIMLIKKARTFOTO] WITH CHECK ADD  CONSTRAINT [FK_KIMLIKKARTFOTO_HKIMLIK] FOREIGN KEY([HKIMLIKID])
REFERENCES [dbo].[HKIMLIK] ([HKIMLIKID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_KIMLIKKARTFOTO_HKIMLIK]') AND parent_object_id = OBJECT_ID(N'[dbo].[KIMLIKKARTFOTO]'))
ALTER TABLE [dbo].[KIMLIKKARTFOTO] CHECK CONSTRAINT [FK_KIMLIKKARTFOTO_HKIMLIK]
GO