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.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Algorithm Implementation

Author  Topic 

wazuba
Starting Member

4 Posts

Posted - 2009-12-11 : 17:22:27
Hi all,

I am trying to implement a certain algorithm using SQL server 2008 (Express edition).
Basically I want to divide a certain geographical area into 3d cubes and calculate the distance of each cube from all the other cubes.
Brute force calculations are not feasable (at least what I have tried)
So I want to divide my space into 9 cubes and then each cube into 9 more cubes in a sort of divide and conquer style. while any cubes that are more than a certain distance apart I don't want to even calculate thier distances.
The coordinates of each cube are X,Y,Z and T (time).
X goes from 0 to 10 miles in 0.25mile increments.
Y goes from 0 to 10 miles in 0.25mile increments.
Z goes from 0 to 4 miles in 0.25mile increments.
T goes from 0 to 24 hours in 1 minute increments


Any ideas on how I should go about doing this in SQL server?

Thanks!!

edit: moved to correct forum

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-11 : 18:00:49
This doesn't sound like it should be done inside SQL Server. T-SQL isn't meant for calculations like this. Can't you do it from an application?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

wazuba
Starting Member

4 Posts

Posted - 2009-12-11 : 19:13:01
Umm... They are not very complicated calculations it's just euclidean distances.
And I need it to be an SQL database of the cubes in the end.
Do you think sending a query to the DB through a C# app for example would be better?
Won't the queries take longer?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-11 : 20:35:12
If you were using SQL Server 2005 or 2008, then I'd recommend putting it into a .NET CLR object. But it appears you are on 2000, so you don't have the .NET framework available to you inside the database.

I don't have the answer as to what it would look like written in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

wazuba
Starting Member

4 Posts

Posted - 2009-12-12 : 04:48:20
I am using SQL 2008....I posted in the wrong forum...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-12 : 13:04:53
Then I'd highly suggest doing it in a .NET CLR object. You can use C# or any other .NET programming language inside the database.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -