If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Special Query Construction

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-01-03, 02:00
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Special Query Construction

I have a query that I am building, that I am having a tough time getting a handle on. What I have are tables like the following:

CREATE TABLE fv (
vectorid INT UNSIGNED NOT NULL AUTO_INCREMENT,
dimension INT UNSIGNED NOT NULL,
value FLOAT NOT NULL,
PRIMARY KEY(dimension, vectorid)
);

CREATE TABLE centers (
centerid INT UNSIGNED NOT NULL AUTO_INCREMENT,
dimension INT UNSIGNED NOT NULL,
value FLOAT NOT NULL,
PRIMARY KEY(dimension, centerid)
);

CREATE TABLE selected (
selectid INT UNSIGNED NOT NULL AUTO_INCREMENT,
centerid INT UNSIGNED NOT NULL,
PRIMARY KEY (centerid, selectid)
);

I want to select records out of the centers table based on the centerid values in the selected table for a specific selectid value. Then I want to join the fv table to the centers table using dimension and a specific number of random vectorid values. To make things a little more difficult, the query should return a single centerid associated with a single vectorid. What would be the best method of attack? I am using Python for the application logic.
Reply With Quote
  #2 (permalink)  
Old 11-01-03, 11:12
bstjean bstjean is offline
Registered User
 
Join Date: Sep 2002
Location: Montreal, Canada
Posts: 219
Re: Special Query Construction

Quote:
Originally posted by aus
I have a query that I am building, that I am having a tough time getting a handle on. What I have are tables like the following:

CREATE TABLE fv (
vectorid INT UNSIGNED NOT NULL AUTO_INCREMENT,
dimension INT UNSIGNED NOT NULL,
value FLOAT NOT NULL,
PRIMARY KEY(dimension, vectorid)
);

CREATE TABLE centers (
centerid INT UNSIGNED NOT NULL AUTO_INCREMENT,
dimension INT UNSIGNED NOT NULL,
value FLOAT NOT NULL,
PRIMARY KEY(dimension, centerid)
);

CREATE TABLE selected (
selectid INT UNSIGNED NOT NULL AUTO_INCREMENT,
centerid INT UNSIGNED NOT NULL,
PRIMARY KEY (centerid, selectid)
);

I want to select records out of the centers table based on the centerid values in the selected table for a specific selectid value. Then I want to join the fv table to the centers table using dimension and a specific number of random vectorid values. To make things a little more difficult, the query should return a single centerid associated with a single vectorid. What would be the best method of attack? I am using Python for the application logic.
Your description is not clear. Can you provide us with some data and the expected result?
Reply With Quote
  #3 (permalink)  
Old 11-01-03, 12:27
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Here is a mysqldump file with partial data. The structure of the desired result would be:

fv.dimension, fv.value + centers.value

I want results for only two centerids from centers with one result for each dimension. The centerids will be specified in selected, but the two vectorids from fv must be random.
Attached Files
File Type: txt sample.txt (1.8 KB, 34 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On