These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Requesting examples of queries for the eve static database

Author
Optionyst
Total HellDeath Incorporated
#1 - 2012-04-15 15:20:12 UTC
Hi,

I successfully downloaded and restored the eve static dump database file. Now i would like to know if there is a way to write a query that returns something like every modules in the game, with their unique id , name and description.

Is this even possible ? I tried looking on evedev wiki, but found nothing concerning queries for items.

sorry if this is a repost. If there is any good tutorial around, please refer me to it. ( or if you can write the query itself, it would be even better) I have basic SQL knowledge.

Desmont McCallock
#2 - 2012-04-15 15:56:05 UTC  |  Edited by: Desmont McCallock
SELECT invTypes.typeID, invTypes.typeName, invTypes.description
FROM invTypes
LEFT JOIN invGroups ON invTypes.groupID = invGroups.groupID
WHERE invTypes.published = 1 AND invGroups.categoryID = 7

Explanation: We are combining invTypes and InvGroups table with 'Left Join' and then filtering out any item that is not published ingame and doesn't belong in the category 7 (modules). Filtering of the category is possible due to invGroups table.
Optionyst
Total HellDeath Incorporated
#3 - 2012-04-15 16:43:20 UTC
Thank you so much :) from there i should be able to figure out the rest.
LifeHatesMe
LifeHatesUsAll
#4 - 2012-04-15 23:13:17 UTC
You may want to check this page out too;

http://wiki.eve-id.net/SQL_Methods_on_the_dump

Also, I highly reccomend that you check out INNER JOIN, and OUTER JOIN statements :) (Maybe even conditionals, and switches)
Optionyst
Total HellDeath Incorporated
#5 - 2012-04-16 03:17:12 UTC
i'm more used to oracle and sql, and i didn't learn any LEFT or INNER or such terms. usually it was only WHERE Table1.col=Table2.col AND Table1.id= "value" so yeah i guess i'll check it out !

For those who really dont like SQL, you can always use Evemon's binaries. there are useful xml files in there too.
LifeHatesMe
LifeHatesUsAll
#6 - 2012-04-16 04:21:19 UTC
Optionyst wrote:
i'm more used to oracle and sql, and i didn't learn any LEFT or INNER or such terms. usually it was only WHERE Table1.col=Table2.col AND Table1.id= "value" so yeah i guess i'll check it out !

For those who really dont like SQL, you can always use Evemon's binaries. there are useful xml files in there too.
Well.. normalization in eve is very consistent. Meaning if you want to get something readable, your usually looking at linking 2-3 different tables of data to get a rowset you'd find interesting.

Once you get the knack of it, it's not bad :)
Dragonaire
Here there be Dragons
#7 - 2012-04-16 05:29:45 UTC
Anyone want to work with the SDD needs to spend some time to really learn about database normalization as well as how to make optimized joins etc as it'll pay off. As pointed out you'll be using a lot of joins and they can be either of the WHERE Table1.col=Table2.col or the full join syntax. Once you get use to the full join syntax it can be easier to use when you join 3 or more tables and you should end up with fewer queries that don't seem to work like you expected. Outer joins can be especially useful when working with optional data results.

Finds camping stations from the inside much easier. Designer of Yapeal for the Eve API. Check out the Yapeal PHP API Library thread.

Optionyst
Total HellDeath Incorporated
#8 - 2012-04-16 14:22:43 UTC  |  Edited by: Optionyst
since people are friendly, i'd need help with this query.

my ultimate goal is to display the full marketGroup tree for an item.

right now, this should return one row per level of recursion, but somehow i get "max lvl of recursion reached" meaning my stop criteria must be wrong.


WITH marketparent ( marketGroupID,parentGroupID, marketGroupName, level)

AS

(

SELECT market.parentGroupID, market.marketGroupID, market.marketGroupName, 0 AS Level
FROM EVE.dbo.invMarketGroups as market
INNER JOIN EVE.dbo.invTypes as inv
ON market.marketGroupID = inv.marketGroupID
WHERE parentGroupID IS NULL
UNION ALL

SELECT market.parentGroupID, market.marketGroupID, market.marketGroupName,Level +1
FROM EVE.dbo.invMarketGroups as market
INNER JOIN EVE.dbo.invTypes as inv
ON market.marketGroupID = inv.marketGroupID
INNER JOIN marketparent as mp
ON market.parentGroupID=mp.marketGroupID
)


SELECT mp.parentGroupID, mp.marketGroupID, mp.marketGroupName, Level
FROM marketparent as mp

INNER JOIN EVE.dbo.invTypes as inv
ON mp.marketGroupID = inv.marketGroupID
WHERE inv.marketgroupID = 306 OR Level = 0; --306 is just a test
LifeHatesMe
LifeHatesUsAll
#9 - 2012-04-16 17:45:36 UTC  |  Edited by: LifeHatesMe
Optionyst wrote:
stuff
I get what your trying to do.. and I don't think there is a very easy way to do it. Recursion is a complicated subject. I did find this page online;

http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html

Although that's for MySQL, your SQL looks different from what I'm using.. !

In their example, they gave this;
SELECT
CONCAT( SPACE(2*COUNT(parent.nodeid)-2), PersonName(child.nodeid) )
AS 'The Shakespeare Family Tree'
FROM nestedsettree AS parent
INNER JOIN nestedsettree AS child
ON child.leftedge BETWEEN parent.leftedge AND parent.rightedge
GROUP BY child.nodeid
ORDER BY child.leftedge;
+-----------------------------+
| The Shakespeare Family Tree |
+-----------------------------+
| (indented list of nodes) |
+-----------------------------+

Ahh, this guy sorta cheated in a way, with the ordering stored manually.. The best way I can think of this without being at home would be to add in so many INNER JOINS that at some point you return null sets. The majority of methods involve either setting up database views, or stored procedures. If you use a scripting language, like php, you just write either a recursive function, or loop till you can't pull anymore data. (IE; you reach parentGroupID = NULL in invMarketGroups)
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#10 - 2012-04-16 19:14:45 UTC
If you're comfortable in Oracle, why not use Oracle Express Edition?

It'd even make the recursive stuff easy, with connect by. http://www.adp-gmbh.ch/ora/sql/connect_by.html

Only reason I'm not using it on my server is that I can't be bothered upgrading it to a 64 bit OS (as express edition is 64 bit only, on linux)

You'd have to migrate the data, but I believe that SQL Developer has the toolset to do that.http://www.oracle.com/technetwork/database/migration/sqlserver-095136.html

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

LifeHatesMe
LifeHatesUsAll
#11 - 2012-04-17 00:45:52 UTC
Steve Ronuken wrote:
If you're comfortable in Oracle, why not use Oracle Express Edition?

It'd even make the recursive stuff easy, with connect by. http://www.adp-gmbh.ch/ora/sql/connect_by.html

Only reason I'm not using it on my server is that I can't be bothered upgrading it to a 64 bit OS (as express edition is 64 bit only, on linux)

You'd have to migrate the data, but I believe that SQL Developer has the toolset to do that.http://www.oracle.com/technetwork/database/migration/sqlserver-095136.html

Fascinating, apparently MySQL 5.x is supposed to have a connect by equivalent, but due to bugs, they disabled it's functionality.
Optionyst
Total HellDeath Incorporated
#12 - 2012-04-20 02:33:24 UTC  |  Edited by: Optionyst
fixed.