SQL Server 2014中全文搜索的最佳数据结构

时间:2015-11-05 08:09:50

标签: sql-server tsql sql-server-2014

以下是一个人为的简化示例:

USE Test;

IF OBJECT_ID('dbo.Books', 'U') IS NOT NULL
      DROP TABLE dbo.Books; 

IF OBJECT_ID('dbo.Authors', 'U') IS NOT NULL
      DROP TABLE dbo.Authors; 

CREATE TABLE dbo.Authors
(
        AuthorId BIGINT NOT NULL PRIMARY KEY IDENTITY(1,1), 
        AuthorName NVARCHAR(MAX) NOT NULL   
)

CREATE TABLE dbo.Books
(
        BookId BIGINT NOT NULL PRIMARY KEY IDENTITY(1,1), 
        BookTitle NVARCHAR(MAX) NOT NULL,   
        FirstAuthorId BIGINT NOT NULL,
        CONSTRAINT [FK_BookToFirstAuthor_Authors] FOREIGN KEY([FirstAuthorId]) REFERENCES Authors([AuthorId])
)

这对于CONTAINS和(第一个)BookTitle中的全文搜索(例如通过AuthorName)是否足够有效?

或者这样的事情会更好:

CREATE TABLE Books
(
    BookId BIGINT NOT NULL PRIMARY KEY IDENTITY(1,1), 
    BookTitle NVARCHAR(MAX) NOT NULL,   
    FirstAuthorId BIGINT NOT NULL,
    FirstAuthorName NVARCHAR(MAX) NOT NULL, 
    CONSTRAINT [FK_BookToFirstAuthor_Authors] FOREIGN KEY([FirstAuthorId]) REFERENCES Authors([AuthorId])
)

请注意,我看到Book行像不可变'对象'。任何反馈都将非常感激。非常感谢。

0 个答案:

没有答案