以下是一个人为的简化示例:
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行像不可变'对象'。任何反馈都将非常感激。非常感谢。