开发者

SQL Server Indexed view for Full Text Search

开发者 https://www.devze.com 2023-01-12 03:21 出处:网络
I want to use the Ful开发者_C百科l Text Search feature of Microsoft SQL Server. If I have a table Client which refers other tables like City, Country, Department, etc. is it better to create a separa

I want to use the Ful开发者_C百科l Text Search feature of Microsoft SQL Server.

If I have a table Client which refers other tables like City, Country, Department, etc. is it better to create a separate table that would hold de-normalized data, which would then be full text indexed, or is it better to create a dummy value in every foreign table (for instance with key -1 ) and then substitute the NULLs from the Client table with those corresponding dummy values, then create an indexed view (those dummy entries are because of the indexed view and the use of 'inner join' instead of 'left join') and then create a full text index on this index view?

With the latter I wouldn't have to worry about populating the 'de-normalized' table every time a record changes in the Client, or in any of the foreign tables - City, Country, Department, etc.

Or maybe none of the above, I could use some new ideas as well :)


None of the above.

Keep the data normalized and create separate FT indexes on each normalized table. When querying the data, query the relevant table. If you want a query to span multiple tables (eg. if either City, Country or Department contain 'York') then use normal query UNION operators to aggregate searches across multiple tables. This is how FT works, so keep your design aligned with the way the feature works. Don't try to cheat, you're only going to burn yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号