具有 Allow Null true 列的复合主键
Composite Primary Key having column with Allow Null true
我想知道最佳实践。
我有一个 table 委员会, Application,EmpInternal 和 EmpExternal
Committee的主键是一个复合Key,由ApplicationID, EmpInternalID[组成=30=] 和 EmpExternalID
现在,AllowNull 属性 不允许在复合键的列中为真。我应该怎么做才能将委员会成员存储在有时是内部和外部的委员会 table 中。所有列 ApplicationID、EmpInternalID 和 EmpExternalID 都是 autonumber在他们各自的 tables
CREATE TABLE [dbo].[Employee](
[EmployeeID] [varchar](10) NOT NULL,
[UserID] [varchar](100) NULL,
[Title] [varchar](50) NULL,
[Name] [nvarchar](240) NULL,
[Rank] [varchar](150) NULL,
[Department] [varchar](240) NULL,
[College] [varchar](240) NULL,
[POBox] [varchar](120) NULL,
[Phone] [varchar](60) NULL,
[JoinDate] [varchar](200) NULL,
CONSTRAINT [PK_Employee1] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
CREATE TABLE [dbo].[EmployeeExternal](
[EmployeeExID] [varchar](10) NOT NULL,
[Title] [nvarchar](50) NULL,
[Name] [nvarchar](50) NULL,
[Rank] [nvarchar](50) NULL,
[Department] [nvarchar](4000) NULL,
[Organization] [nvarchar](4000) NULL,
[Address] [nvarchar](4000) NULL,
[Email] [nvarchar](50) NULL,
[Email2] [nvarchar](50) NULL,
[Phone] [nvarchar](50) NULL,
[Mobile] [nvarchar](50) NULL,
[Country] [nvarchar](50) NULL,
CONSTRAINT [PK_Employee1] PRIMARY KEY CLUSTERED
( [EmployeeExID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
Employee table 和 EmployeeExternal table 中的标志记录是比合并这些更好的解决方案两个 table。复合键中标记记录的键删除复合键中 null 的使用
我想知道最佳实践。 我有一个 table 委员会, Application,EmpInternal 和 EmpExternal Committee的主键是一个复合Key,由ApplicationID, EmpInternalID[组成=30=] 和 EmpExternalID
现在,AllowNull 属性 不允许在复合键的列中为真。我应该怎么做才能将委员会成员存储在有时是内部和外部的委员会 table 中。所有列 ApplicationID、EmpInternalID 和 EmpExternalID 都是 autonumber在他们各自的 tables
CREATE TABLE [dbo].[Employee](
[EmployeeID] [varchar](10) NOT NULL,
[UserID] [varchar](100) NULL,
[Title] [varchar](50) NULL,
[Name] [nvarchar](240) NULL,
[Rank] [varchar](150) NULL,
[Department] [varchar](240) NULL,
[College] [varchar](240) NULL,
[POBox] [varchar](120) NULL,
[Phone] [varchar](60) NULL,
[JoinDate] [varchar](200) NULL,
CONSTRAINT [PK_Employee1] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
CREATE TABLE [dbo].[EmployeeExternal](
[EmployeeExID] [varchar](10) NOT NULL,
[Title] [nvarchar](50) NULL,
[Name] [nvarchar](50) NULL,
[Rank] [nvarchar](50) NULL,
[Department] [nvarchar](4000) NULL,
[Organization] [nvarchar](4000) NULL,
[Address] [nvarchar](4000) NULL,
[Email] [nvarchar](50) NULL,
[Email2] [nvarchar](50) NULL,
[Phone] [nvarchar](50) NULL,
[Mobile] [nvarchar](50) NULL,
[Country] [nvarchar](50) NULL,
CONSTRAINT [PK_Employee1] PRIMARY KEY CLUSTERED
( [EmployeeExID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
Employee table 和 EmployeeExternal table 中的标志记录是比合并这些更好的解决方案两个 table。复合键中标记记录的键删除复合键中 null 的使用