Forum Moderators: coopster

Message Too Old, No Replies

opinion on database field create

the field creation of mysql database

         

threebytes

5:01 am on Dec 13, 2003 (gmt 0)

10+ Year Member



i would like save three values into members table. "win, lost and draw" for example. now the question comes like this. which ways you think is the better or you could suggest a more efficient way of doing that.

my idea was
1. create three field in the table and store the 3 values separetely.
- pretty easy by where have 3 field and store the 3 in different value into their field.
2. create one filed by then store the 3 values together. (not sure whether this work or not, just an idea )
- create only one field then store the value 12,3,2 (12 is the win, 3 is the lost, and 2 would be lost) in the the field.

the reason i comes up with the idea 2 is i don't want to waste up too much of space on the database and takes up the bandwidth. by where i know that in MSaccess at where the more field you have, the larger the database will be.(takes up more space then the records do) i not sure about mysql since i find the space used by mysql was pretty little. do u agreed with the idea 2? why and why not. (if yes would you show me the way of displaying the value separetely after retieved from database)

Robino

5:14 am on Dec 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello threebytes.

You could try this (#1) with two fields.

action_id: 1
action_name: win

action_id: 2
action_name: lose

etc...

threebytes

5:56 am on Dec 13, 2003 (gmt 0)

10+ Year Member



sorry Robino, i not sure what you mean by that .
but i think you miss understood me.

i would like to store number of wins, loses, draws into the database field. which mean how many times the members win in a game, loses and etc.

NickCoons

7:22 am on Dec 13, 2003 (gmt 0)

10+ Year Member



This is a trade off between space used to store the data (option #1) and processing power used to interpret them (option #2). Personally, I'd stick with storing the values seperately since accessing them will be much faster. Plus, they can be stored as integers, whereas storing them all in one field would mean that you'd have to use a text field, which may not really save you any space at all.

threebytes

2:02 pm on Dec 13, 2003 (gmt 0)

10+ Year Member



thanks NickCoons, you helped me alot.