设计数据库,是否拆分表?

时间:2014-07-23 19:52:35

标签: database

我有一个类别,如下:

CREATE TABLE [dbo].[FaqCategorie](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Naam] [nchar](50) NULL,
 CONSTRAINT [PK_FaqCategorie] PRIMARY KEY CLUSTERED 
(
    [Id] 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

SubCategorie:

CREATE TABLE [dbo].[FaqSubCategorie](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Naam] [nchar](50) NULL,
    [FaqCategorie_Id] [int] NOT NULL,
 CONSTRAINT [PK_FaqSubCategorie] PRIMARY KEY CLUSTERED 
(
    [Id] 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

ALTER TABLE [dbo].[FaqSubCategorie]  WITH CHECK ADD  CONSTRAINT [FK_FaqSubCategorie_FaqCategorie] FOREIGN KEY([FaqCategorie_Id])
REFERENCES [dbo].[FaqCategorie] ([Id])
GO

ALTER TABLE [dbo].[FaqSubCategorie] CHECK CONSTRAINT [FK_FaqSubCategorie_FaqCategorie]
GO

和常见问题:

REATE TABLE [dbo].[Faq](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Vraag] [nvarchar](max) NULL,
    [Antwoord] [nvarchar](max) NULL,
    [Score] [int] NULL,
 CONSTRAINT [PK_Faq] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

所以分类有更多的SubCategorie项目。在常见问题中有一个vraag(qusetion)antwoord(answare)一个子类别可以有更多的常见问题。一个Vraag可以有一个antwoord。但现在是我的问题。一个vraag怎么知道女巫answares与eatch其他相关?所以有必要 将Faq拆分为两个表格:Vraag en Antwoord然后建立一对一的关系?

谢谢

0 个答案:

没有答案