Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Storing database data into Map

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 20-02-2010
Member
 
Join Date: Dec 2009
Posts: 292
Storing database data into Map
  

Hello,
I have a table in DB that contains the code for an action in the stock market, date and value of this action to date. I am interested only 5 dates per share. I want a simple structure, with, if we consider a table, an action line. Style a table of 6 columns with the code share, the value today, the value of last month, the value. I immediately thought of a table, but is that what are faster in Java? Then I'll have to easily access the values of a share from its code. So I need some kind of index on the action code, that's why I thought of a Map. I tell myself I can do a Map containing the key code of the action and enhance an array of 5 values of my action: I think it's a problem that is often faced, having to store data from a database in a table or a Map and would like your opinion on my idea Map (key, table).

Reply With Quote
  #2  
Old 20-02-2010
Member
 
Join Date: Nov 2009
Posts: 335
Re: Storing database data into Map

Hello,
I think you should do.
- array (or List) ==> to use lists 'ordered'.
- Map ==> to use pairs of key / value can easily find a particular value.
The table may be quicker to access an item, but if you must go half the table to find a particular item is useless. To me the Solution Map (key | table) seems correct. The Map allows you to access a particular action quickly. The table allows you to display different dates, especially if these different times are identical as seems to be the case.
Reply With Quote
  #3  
Old 20-02-2010
Member
 
Join Date: Dec 2009
Posts: 202
Re: Storing database data into Map

Hello,
Even I am trying a similar kind of a program to do , but still do not have any solution for this. I wanted to have an opinion on my solution, just to see if I can not miss a great method to kill to solve my problem. I hope it will serve other people, since it is not always easy to choose the data structure, especially when he begins to have multiple dimensions. Any idea no this, any information on this is going to help me, so please guys post back soon.
Reply With Quote
  #4  
Old 20-02-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Storing database data into Map

Hello,
As you program in Java, why do not you object? Instead of storing your actions in a table with 6 columns, you should put them into objects. You see, it's much easier to read and change: a name attribute is even more telling when an index table. Afterwords, as stated as the above post, you can store your Action objects in a table or in a map according to your needs.
Reply With Quote
  #5  
Old 20-02-2010
Member
 
Join Date: Nov 2009
Posts: 343
Re: Storing database data into Map

Hello,
I'm not an expert on the subject. But I think it is possible that access to atttribut class are a bit longer than an element of an array.
Just write a small program that verifies:
- fill a table with 1 row and n columns;
- it fills an object with n attributes of same type as the array elements;
Now, it does not necessarily watch the performance at any price. Especially on a small number of accesses the difference will be minimal. When you see the flexibility is gained, in my opinion where the picture is better is very marginal. In addition, an array contains elements that only one type, while in your object, you can store anything you want: if one day you have new needs, such as storing more the wording of the Action How you gonna do with your picture?
Reply With Quote
  #6  
Old 20-02-2010
Member
 
Join Date: Dec 2009
Posts: 292
Re: Storing database data into Map

Hello,
It is true that the flexibility and clarity of the code are things primordial. I also think they should (although I do not do it all the time but I will force myself a bit) More often construct objects to model data structures (as we have a database create objects that represent the data tables). Code maintenance is really easy because the code is much clearer, even if at that moment it feels to lose a little time. And then it can be much more flexible if it wants to modify the database behind. I think I'm going to force a little more to create objects for a code really clean, because it is often more important than pure performance.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Storing database data into Map"
Thread Thread Starter Forum Replies Last Post
Adobe Flash Player 10.3 block sites from storing Flash data on your computer Pransukh Windows Software 5 05-07-2011 09:40 PM
My data does not fit in my database Happy46 Software Development 3 21-10-2009 06:08 PM
Storing data on disk Linux from Windows SSupDawg Operating Systems 6 26-03-2009 09:59 AM
Storing images in SQL database using Asp.net Booth Software Development 2 17-01-2009 05:25 PM


All times are GMT +5.5. The time now is 04:54 PM.