SQl Code表设计

在Asp.net后有很多常用的表结构 membership就是一个典型,除此还有code表

CREATE TABLE [dbo].[CodeTables](
    [CodeTableID] [uniqueidentifier] NOT NULL,
    [ParentCodeTableID] [uniqueidentifier] NULL,
    [Name] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Alias] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Description] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [ItemCodeMinLength] [int] NULL,
    [ItemCodeMaxLength] [int] NULL,
    [CreatedBy] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [LastUpdatedBy] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [LastUpdatedDate] [datetime] NULL,
    [RecordStatus] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_CodeTables] PRIMARY KEY CLUSTERED
(
    [CodeTableID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


CREATE TABLE [dbo].[CodeItems](
    [CodeItemID] [uniqueidentifier] NOT NULL,
    [CodeTableID] [uniqueidentifier] NOT NULL,
    [ParentCodeItemID] [uniqueidentifier] NULL,
    [Description] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Code] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CreatedBy] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [LastUpdatedBy] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [LastUpdatedDate] [datetime] NULL,
    [RecordStatus] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_CodeItems] PRIMARY KEY CLUSTERED
(
    [CodeItemID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


GO
ALTER TABLE [dbo].[CodeItems]  WITH CHECK ADD  CONSTRAINT [FK_CodeItems_CodeTables_1] FOREIGN KEY([CodeTableID])
REFERENCES [dbo].[CodeTables] ([CodeTableID])
ON UPDATE CASCADE
ON DELETE CASCADE

CodeTables的数据如下
A81637CA-1F65-4F4C-8FCA-0FBDD575DBB8    00000000-0000-0000-0000-000000000000    HSE_MEM_STATUS    002    HSE_MEM_STATUS    1    10    admin    2009-02-19 15:10:45.000    admin    2009-02-19 15:10:45.000    A
CodeItems的数据如下
1D32F8C8-7A43-4A99-A36F-701811DFD578    A81637CA-1F65-4F4C-8FCA-0FBDD575DBB8    00000000-0000-0000-0000-000000000000    Completed    C    admin    2009-02-19 17:23:42.000    admin    2009-02-19 17:23:42.000    A

你可能感兴趣的:(sql,c,table,null,delete,asp.net)