Results 1 to 6 of 6

Thread: Storing database data into Map

  1. #1
    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).

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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?

  6. #6
    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.

Similar Threads

  1. Replies: 5
    Last Post: 05-07-2011, 09:40 PM
  2. My data does not fit in my database
    By Happy46 in forum Software Development
    Replies: 3
    Last Post: 21-10-2009, 06:08 PM
  3. Storing data on disk Linux from Windows
    By SSupDawg in forum Operating Systems
    Replies: 6
    Last Post: 26-03-2009, 09:59 AM
  4. Storing images in SQL database using Asp.net
    By Booth in forum Software Development
    Replies: 2
    Last Post: 17-01-2009, 06:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,624,739.25421 seconds with 17 queries