Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
financemanager
Starting Member
9 Posts |
Posted - 2008-03-28 : 04:44:05
|
I have the following to answer, i have never done this can somebody help please...........How do you write a store procedure to meet the following conditions:PROXIMITY SERACH PROCEDURECOMPANY tablePK company_id intcompany_name varchar(100)premise varchar(10)street varchar(30)town varchar(100)postcode char(7)x_loc inty_loc intCOMPANY_KEYWORD tablePK, FK1 company_id intPK keyword varchar(100)The data above shows an extract of a company listings database. The company table holds the name and address of the company as well as a physical location in terms of an Easting and Northing co-ordinate. Each company has one or more keywords or phrases associated with it in the company_keyword table. The full database holds 5 million companies with an average of 4 keywords each,A stored procedure is required to provide proximity searching of the database. The procedure should return a list of companies that satisfy the keyword search expression and fall within the defined maximum distance of the specified location. Results should be limited to show the closest companies up to a maximum of @max_records.proximity_search @search_expression varchar(255),@x_loc int,@y_loc int,@max_distance int ,@max_records intExample Search Expressions@search_expression - DescriptionTESCO AND CASHPOINT - Return all companies that have all of the keywords specified. TESCO OR SAINSBURY’’S - Return all records that have one or more of the keywords specified.TESCO EXPRESS AND CASHPOINT ORSAINSBURY’S LOCAL - Return all companies that have either both of the first two keywords or the third.Distance can be calculated using the following formula:Distance = sqrt( square(x1-x2) + square(y1-y2) )THE QUESTION1. Create a stored procedure to satisfy the requirement shown above2.Comment on the database design and identify any indexes that may be appropriate. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
financemanager
Starting Member
9 Posts |
Posted - 2008-03-28 : 05:58:04
|
hi Peso,Thank you for you prompt reply.....Kind RegardsFinancemanagerKind RegardsPete |
 |
|
gousia
Starting Member
3 Posts |
Posted - 2008-04-08 : 15:57:17
|
Hi There,Just Curious. Did you managed to answer the below question? If Yes, Could you please advice on this?Many Thanks,Gousiaquote: Originally posted by financemanager I have the following to answer, i have never done this can somebody help please...........How do you write a store procedure to meet the following conditions:PROXIMITY SERACH PROCEDURECOMPANY tablePK company_id intcompany_name varchar(100)premise varchar(10)street varchar(30)town varchar(100)postcode char(7)x_loc inty_loc intCOMPANY_KEYWORD tablePK, FK1 company_id intPK keyword varchar(100)The data above shows an extract of a company listings database. The company table holds the name and address of the company as well as a physical location in terms of an Easting and Northing co-ordinate. Each company has one or more keywords or phrases associated with it in the company_keyword table. The full database holds 5 million companies with an average of 4 keywords each,A stored procedure is required to provide proximity searching of the database. The procedure should return a list of companies that satisfy the keyword search expression and fall within the defined maximum distance of the specified location. Results should be limited to show the closest companies up to a maximum of @max_records.proximity_search @search_expression varchar(255),@x_loc int,@y_loc int,@max_distance int ,@max_records intExample Search Expressions@search_expression - DescriptionTESCO AND CASHPOINT - Return all companies that have all of the keywords specified. TESCO OR SAINSBURY’’S - Return all records that have one or more of the keywords specified.TESCO EXPRESS AND CASHPOINT ORSAINSBURY’S LOCAL - Return all companies that have either both of the first two keywords or the third.Distance can be calculated using the following formula:Distance = sqrt( square(x1-x2) + square(y1-y2) )THE QUESTION1. Create a stored procedure to satisfy the requirement shown above2.Comment on the database design and identify any indexes that may be appropriate.
|
 |
|
|
|
|
|
|