Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Geraint

Member Since 13 Dec 2012
Offline Last Active Feb 03 2013 03:26 PM

#5014927 mysql database

Posted by Geraint on 27 December 2012 - 06:23 PM

I'm not quite sure, it just feels more efficient if u could virtually link a user with his own item table, instead of checking one by one every item the user has gotten on a database lots of users are going to use, lets say i have 1000 users and 1000 items, whenever i wanna see items for user 123, i would have to loop through the entire character_item table, to check for his CID, i am fairly new to the database subject but that just feels unefficient, i guess i'm just thinking like object oriented.

 

That's why you use a MySQL database. I'm not sure why you're looping through the entire characther_item database anyway?

 

Joining tables are actually the how relational databases are implemented. Again I recommend reading up on the subject. They are the efficient method of associating tables together when using a database.

 

Example Scenario

 

  1. We have a Character.
  2. We know his unique ID.
  3. We perform a SELECT query.

At no point do you have to iterate through the character_item table?




#5014730 mysql database

Posted by Geraint on 27 December 2012 - 10:38 AM

You can easily have multiple amounts of the same item.

CHARACTER_ITEMS { ID, CID, IID, Amount }

 

Then you merely modify the Amount value to increase or decrease the number of items a character has.

 

The alternative is you store the list of items as comma separated values in the Character Table. However this is highly inefficient and will cause repetition of data, which is what relational databases are designed to eliminate.

 

I don't really see why you're against using a joining table, could you explain your reasons?




#5014638 mysql database

Posted by Geraint on 27 December 2012 - 02:29 AM

I think you're looking for something along the lines of:

 

Character <- Character-Item -> Item

 

Each character has a unique ID.

Each Item has a unique ID.

 

Each time a character "obtains" an item you add a record to the Character-Item table which contains both the unique ID of the character that "obtained" the item and the unique ID of the item that was "obtained".

 

Assuming you used the design that Sollum suggested (which is a very effective one) such that your tables are defined as:

 

 

Table CHARACTER { ID, USER_ID, RANDOM_FIELD_A, ..., RANDOM_FIELD_N }

Table ITEM { ID, RANDOM_FIELD_A, ..., RANDOM_FIELD_N }

 

 

Table CHARACTER_ITEMS { ID, CID, IID, RANDOM_FIELD_A, ..., RANDOM_FIELD_N } (where CID and IID are foreing keys from CHARACTER and ITEM)

 

 

 

That way if you wanted to get what items the character has you would perform a SELECT query such as:

 

SELECT IID FROM CHARACTER_ITEMS
WHERE CID LIKE '0'

 

Which will give you a list of unique IDs for items that a character with the unique ID of 0.

 

I recommend reading up on RDBM as Sollum suggested if this isn't clear to you:

  • Fairly decent article explaining database relationships on TechRepublic: Relational Databases
  • A good article from nettuts+ explaining database relationships (slightly more beginner friendly): Database Relationships

 

If you still need help I wouldn't mind lending a hand if I have some free time so feel free to pop a PM my way.




#5013330 I have a few easy questions about game development. (noob)

Posted by Geraint on 21 December 2012 - 09:33 PM

Willingness to learn is one of the best skills you can have in any subject matter in my opinion.

Java
How much of Java have you learnt?

If you have just started programming then I highly recommend using an Integrated Development Environment rather than attempt to use command line compilers. I personally speaking from experience recommend Eclipse for Java Developers. Alternatively you can also consider Netbeans.

If you choose Eclipse here is a tutorial to get you started. If you really want to know how to compile java code manually through command line then look here.

Khatharr pretty much hit the nail with graphics/model/audio resources and at your stage you don't really have to worry about it farther from being able to make/find placeholder graphics.

C++

There is no easy way to learn C++

So very true. Although funnily enough that is the first language I learnt. From personal experience I highly recommend you stick with Java first until you are competent at it before thinking about switching. (Get to the point where you know about object oriented concepts such as inheritance, polymorphism, etc.)

If you are crazy (like I was) and for some reason want to start with C++ then I recommend the following sites.
cplusplus.com
cprogramming.com

In terms of software there is a plugin for Eclipse which allows you to use it for C++ as well (A quick google search should give you a tutorial on how to setup eclipse for C++) or you can use Visual C++ Express.

Hope that information helps and good luck.




#5011964 Best engine for Diablo style game?

Posted by Geraint on 18 December 2012 - 03:03 AM

Both Torchlight and Torchlight II use the OGRE 3D Graphics Engine I believe, however this is of course only a graphics engine.

Any particular specific requirements for your engine?

Personally I'd recommend the Unity engine which uses C# for scripting. (The transition shouldn't be difficult if you already know C and Java.) If you'd like to stick to using Java then there's the jMonkeyEngine.

Hope that helps.


PARTNERS