Author Topic: Database  (Read 172 times)

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« on: November 25, 2010, 05:09:26 am »


               I know this probably isn't the correct location to ask this question but I didn't find a place for it.

So here's my question:
What database should I use with NWNx?

Kinda would like to use something fairly easy to understand and use but effiecent.. Any ideas?
               
               

               
            

Legacy_Psyammy

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
Database
« Reply #1 on: November 25, 2010, 11:27:35 am »


               MYSQL is good.

http://dev.mysql.com/downloads/

(i am useing it with NWNX2)

Psyammy
               
               

               


                     Modifié par Psyammy, 25 novembre 2010 - 11:31 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Database
« Reply #2 on: November 25, 2010, 12:58:29 pm »


               mySQL Via nwnx / aps_include is perhaps the best of them all.



When stress tested, against all the competitors, mySQL is able to complete the most amount of queries in the least amount of time.



And since nwnScript is Synchronous, the longer a query takes to complete, that is time that your server/game is locked up.



eg - 1000 Inserts into bioware database I think had about 1000ms delay before completing.

 Thats a whole second where your server will have froze for all players playing it.



Similar queries done on mySQL and SQLite had average completion times of less than a hundred miliseconds or so.



If you run the database server locally to the game server, you are guaranteed to have a query time of less than 20ms in most cases.



Note - SQLite which ships with nwnx, is good, but not as good as mySQL, SQLite also has some subtle syntax changes and differences, and the speed is not as good as mySQL since it is still a File I/O operation being conducted on the database file.





Database functionality also allows you to expand your game server out of the server world, and into the real world.

Integration with websites, forums, etc are some of things I have done in the past, as well as even creating a system that allowed me to create items on the fly, via a browser interface.



Database functionality may sound like a small building block, but it can enable you to accomplish really impressive feats of ingenuity if you have the imagination to use it.
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« Reply #3 on: November 25, 2010, 02:47:53 pm »


               *nods* Thanks for the information.. Does it make a difference which type of Mysql if I'm going to place it on a IBM Server class computer which the O/S is windows server 2003?
               
               

               


                     Modifié par Taino, 25 novembre 2010 - 02:58 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Database
« Reply #4 on: November 25, 2010, 06:30:05 pm »


               Generally speaking, mySQL is the same accross the board.

Except that in higher version numbers, you get more functionality, eg - more function keywords etc, store procs etc,



I would go for the community edition, as its free, and does everything you need.

If hosting it on a separate machine than your nwn server, make sure the ping to the mySQL database is small, otherwise it will freeze ur module.



eg - Database queries are synchronous - meaning they will pause the gameplay, while they wait for the query to complete.



I run my mySQL database on the same machine as my Server, it means the ping is always <0 because its going from localhost to localhost.
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« Reply #5 on: November 25, 2010, 07:52:24 pm »


               Yes I am or will be installing onto my Server. Where the module will be running on as well.



Another question, would there be examples on how to create the tables? I have worked with WAMP5 a bit. But when I tried to install it onto that IBM Server it went goofy on me. If it is similar to creating the tables like in WAMP5 then I can manage it.
               
               

               
            

Legacy_KenquinnTheInsaneOne

  • Newbie
  • *
  • Posts: 48
  • Karma: +0/-0
Database
« Reply #6 on: November 25, 2010, 07:53:24 pm »


               MySQL syntax is very simple to use and there are a number of good tutorials out there for it.

SELECT deadorcs FROM orckills WHERE player='Baaleos';

Is a simple fetch statement in MySQL that selects the value deadorcs(could be a variable or string) from a table called orckills where the player is Baaleos. You do not have to use custom fetch statments there are a few functions included in the aps_inlcude script for mannipulating data, but direclty getting/setting/creating data with fetches is much more powerfull.

The NWScript code when dealing with the ODBC plugin is slighly more complex that the fetch I just gave, but it is not too complex.
               
               

               


                     Modifié par KenquinnTheInsaneOne, 25 novembre 2010 - 07:53 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Database
« Reply #7 on: November 25, 2010, 10:54:37 pm »


               Note - The Linux version of odbc currently allows for recursive looping in queries, but windows does not.



Its just because the linux version of the plugins get more attention from the plugin creators.



eg

It would allow you to do the following in linux



select * from blah where something = '444'



while(SQLFetch() == SQL_SUCCESS)

   {

         string sNewSearch = "select * from blah2 where something = '"+SQLGetData(1)+"'"

         SQLExecDirect(sNewSearch)

   }



Ordinarily, on a windows version of this, the SQL Query inside the loop, wipes the contents of SQLFetch, breaking the loop, meaning that queries within query loops are currently not easilly accomplished via windows.



So, just take note - there are subtle differences between linux and windows odbc
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« Reply #8 on: November 26, 2010, 12:30:29 am »


               Hmm... I'm running windows server 2003 on that IBM. So I know I can add linux to it to the server but  really don't want to have two different o/s running.



I will keep this in mind. Thanks and of there is anything else I need to know I'll post up.
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« Reply #9 on: December 26, 2010, 04:40:32 pm »


               Okay, I got MySQL installed but the configuration part is hanging up, not responding. I've un-installed it and reinstalled it. Same problem had occurred, which I have don't this possess several times over and over again with the same ending results. I have also read thru the forums about it but of course no luck.



Any advise what should I do next?
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Database
« Reply #10 on: December 28, 2010, 01:12:15 am »


               I guess the MySQL 5.5 liked my server better then the other versions. Went smooth as can be.