My task is to make a little searchengine for internal use at an architect office. They have about 1 000 DWG-details that they re-use every now and then. Unfortunately, finding the right detail is not very easy. Therefore they decided they wanted the possibility to do a quick search instead of going through 1 000 papersheets every time they needed a detail.First of all, there is a predefined set of search keywords. Every detail will be given the appropriate keywords from this list. Due to this I made three tables:tblDetails (DetailID is autonumber and primary key, Detail is text)DetailID | Detail ------------------ 1 | P00001 2 | P00002 3 | P00003etc.
tblKeywords (KeywordID is autonumber and primary key, Keyword is text)KeywordID | Keyword-------------------- 1 | Vertical 2 | Horisontal 3 | Glass 4 | Walletc. (at the moment there's about 34 keywords in this table)
tblConnected (DetailID and KeywordID are Long integers)DetailID | KeywordID-------------------- 1 | 1 1 | 4 2 | 1 2 | 3 2 | 4 3 | 2 3 | 3etc.
I am not quite sure this is the best way to build the DB, but it was the best I could think of at the time (suggestions on how to rebuild the db would be much appreciated).Anyway, the search will be done from an ASP based webpage. The interface will have one checkbox for every single keyword in the database. The user selects some of the keywords the detail needs to have and starts the search. Now, this is where the trouble starts.First of all I need the query to return every detail that contains the keyword the user checked. Secondly I would also like it to return the number of keywords this detail actually is connected to in the DB.So if a user checks Vertical and Wall, the query would return P00001 (2 (for two keywords in total)) and P00002 (3). If the user also checks glass it would return only P00002 (3).The thing is, I can't get the query to work. Due to how tblConnected is built, I am having big problems getting it to return the correct result.The query would have to accept variables from ASP, something likeWHERE keywordID = @keywordId1AND keywordID = @keywordID2AND keywordID = @keywordID3AND keywordID = @keywordID4AND keywordID = @keywordID5etc.
Does anyone understand what I'm talking about? Can somebody please help me build the query (as an SQL query I can run directly in Access, converting it to ASP is no problem), because I am totally lost.