Results 1 to 2 of 2
  1. #1
    JavaDreams is offline Member
    Join Date
    Jan 2011
    Rep Power

    Unhappy DataBase table Design

    Hello Every one!!
    I want to create a database for storing Messages sent to user.I did'nt posted this in database section, because i though it's too basic for that place.

    so how to design it so that i can fine the messeges from userId, do i need to alot a Unique id to each message??
    Can you tell me the most efficient way to create such a table.
    Please Help!!
    Last edited by JavaDreams; 02-18-2011 at 09:28 PM. Reason: Now see the table in the hyperlink!

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Rep Power


    Well, depends on wether you are trying to connect to an actual database (MySQL, Oracle, SQLite, etc...) or are just kinda 'making your own'.

    If the first case, you can use one of the java database connectors, but you will need to have the database up and running first.

    In the second case, there are MANY ways to do this. This is really a data structures question. You can approach it several ways:
    If every user has a Name, ID pair, then anything from a simple array to a HashMap would work.

    You need to identify key goals:
    - Do you need to do lookups by name?
    - Do you need to be able to search the list of users by name efficiently?
    - Do you need to be able to do partial string searchers (search for 'rob' to finder 'Robert Johnson')
    - Do you need to be able to search the list of messages for each user?
    - Does any of this need to be sorted?

    The answers to these questions help determine what structures you need to use. Arrays are simple, but are unsorted and are slow to search. HashMaps are fast to lookup, but you must know the Key to get the Value, and you cannot do it the other way around (Value to find Key).

    An OOP approach might be the simplest to visualize (A User class, MessageList class, etc..) but might not be the most efficient. Can you clarify?

Similar Threads

  1. Replies: 5
    Last Post: 08-16-2010, 04:49 PM
  2. How to display database in table
    By tamnc in forum SWT / JFace
    Replies: 0
    Last Post: 03-15-2010, 05:57 AM
  3. Best way to design a simple database
    By bob89 in forum JDBC
    Replies: 3
    Last Post: 03-08-2010, 04:36 PM
  4. Database and user interface design
    By Implode in forum New To Java
    Replies: 12
    Last Post: 09-14-2009, 12:41 PM
  5. database design for leave management system
    By anji4u_19 in forum JDBC
    Replies: 0
    Last Post: 08-26-2008, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts