if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Key2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Key2]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Key1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Key1]
GO

CREATE TABLE [dbo].[Key2] (
	[Eid] [int] IDENTITY (1, 1) NOT NULL ,
	[E] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Yid] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Key1] (
	[Yid] [int] IDENTITY (1, 1) NOT NULL ,
	[Y] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
	[Yrq] [datetime] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Key1] ADD 
	CONSTRAINT [DF_Y1_Yrq] DEFAULT (getdate()) FOR [Yrq]
GO

