GreetingsHow would I do a similarity matrix using TSQL based on objects that share similar attributes. (http://en.wikipedia.org/wiki/Similarity_matrix)The more attributes they share the higher the score. I am trying to use this as a similarity algorithmThanks sample datadeclare @books TABLE(book_id int, descr nvarchar(50))insert into @books SELECT 1, 'Gone with the wind'UNION ALLSELECT 2, 'Mars'UNION ALLSELECT 3, 'Do Androids Dream of Electric Sheep?'UNION ALLSELECT 4, 'Ender''s Game'UNION ALLSELECT 5, 'Dune'UNION ALLSELECT 6, 'Foundation'UNION ALLSELECT 7, 'Hitch Hiker''s Guide to the Galaxy'UNION ALLSELECT 8, '1984'UNION ALLSELECT 9, 'Star Wars'UNION ALLSELECT 10, 'Battlestar Galactica'UNION ALLSELECT 11, 'Fringe'--SELECT * FROM @booksdeclare @terminologies TABLE(terminology_id int, descr nvarchar(50))INSERT INTO @terminologies SELECT 1, 'Futuristic'UNION ALLSELECT 2, 'Propulsion'UNION ALLSELECT 3, 'Guidance'UNION ALLSELECT 4, 'Life Support'UNION ALLSELECT 5, 'Cabin Structure'UNION ALLSELECT 6, 'Communications'UNION ALLSELECT 7, 'Thermal Protection'UNION ALLSELECT 8, 'Displays And Controls'UNION ALLSELECT 9, 'Space Craft'UNION ALLSELECT 10, 'Light Speed'UNION ALLSELECT 11, 'Warp Speed'UNION ALLSELECT 12, 'Jedi'UNION ALLSELECT 13, 'Force is weak with you rookie Jedi'UNION ALLSELECT 14, 'Civial War'--SELECT * FROM @terminologiesDECLARE @book_terminologies TABLE(book_id int, terminology_id int)INSERT INTO @book_terminologies ( book_id, terminology_id )SELECT 1, 10UNION ALLSELECT 2, 1UNION ALLSELECT 2, 2UNION ALLSELECT 2, 4UNION ALLSELECT 2, 7UNION ALLSELECT 2, 8UNION ALLSELECT 3, 1UNION ALLSELECT 3, 2UNION ALLSELECT 3, 4UNION ALLSELECT 3, 5UNION ALLSELECT 3, 6UNION ALLSELECT 9, 1UNION ALLSELECT 9, 2UNION ALLSELECT 9, 4UNION ALLSELECT 9, 5UNION ALLSELECT 9, 6UNION ALLSELECT 9, 7UNION ALLSELECT 9, 8UNION ALLSELECT 9, 9UNION ALLSELECT 9, 10UNION ALLSELECT 9, 11UNION ALLSELECT 9, 12UNION ALLSELECT 9, 13SELECT * FROM @book_terminologies bt INNER JOIN @books b ON bt.book_id = b.book_id INNER JOIN @terminologies t ON bt.terminology_id = t.terminology_id
If you don't have the passion to help people, you have no passion