我有一张预订表(用户填写表格以申请预订)。
它有两个部分需要确认。 isReservationAccepted(拒绝,接受,等待)和hasReservationBeenSent(发送,拒绝,等待)
不确定如何构建我的表,考虑为每列创建一个查找表,或者只是将它们创建为int,并且1 =接受/发送,2 =拒绝,3 =等待。
我应该如何为这些条件创建状态表?
答案 0 :(得分:1)
以下是您可以使用的通用结构:
/****** Object: Table [dbo].[LookUpTypes] Script Date: 12/06/2013 10:13:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LookUpTypes](
[LookUpTypeID] [uniqueidentifier] NOT NULL,
[LookUpTypeDescription] [varchar](50) NULL,
CONSTRAINT [PK_LookUpTypes] PRIMARY KEY CLUSTERED
(
[LookUpTypeID] 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
SET ANSI_PADDING OFF
GO
--************************************************
CREATE TABLE [dbo].[LookUpValues](
[LookUpValueID] [uniqueidentifier] NOT NULL,
[LookUpTypeID] [uniqueidentifier] NOT NULL,
[LookUpValue] [varchar](50) NOT NULL,
[LookUpValueDescription] [varchar](255) NULL,
CONSTRAINT [PK_LookUpValues] PRIMARY KEY CLUSTERED
(
[LookUpValueID] 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
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[LookUpValues] WITH CHECK ADD CONSTRAINT [FK_LookUpValues_LookUpTypes] FOREIGN KEY([LookUpTypeID])
REFERENCES [dbo].[LookUpTypes] ([LookUpTypeID])
GO
ALTER TABLE [dbo].[LookUpValues] CHECK CONSTRAINT [FK_LookUpValues_LookUpTypes]
GO