Results 1 to 2 of 2
Thread: DataBase table Design
- 02-18-2011, 09:49 PM #1Member
- Join Date
- Jan 2011
- Rep Power
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.
Last edited by JavaDreams; 02-18-2011 at 10:28 PM. Reason: Now see the table in the hyperlink!
- 02-19-2011, 03:27 AM #2
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?
- By lse123 in forum Advanced JavaReplies: 5Last Post: 08-16-2010, 04:49 PM
- By tamnc in forum SWT / JFaceReplies: 0Last Post: 03-15-2010, 06:57 AM
- By bob89 in forum JDBCReplies: 3Last Post: 03-08-2010, 05:36 PM
- By Implode in forum New To JavaReplies: 12Last Post: 09-14-2009, 12:41 PM
- By anji4u_19 in forum JDBCReplies: 0Last Post: 08-26-2008, 11:27 AM