MySql tables

I

Ike

I have a hashmap (or an arraylist), what kind of data type would I specify
this as in creating it's column in a MySql table. How do you store such a
data structure typically in a database???

Thanks, Ike
 
R

Roedy Green

I have a hashmap (or an arraylist), what kind of data type would I specify
this as in creating it's column in a MySql table. How do you store such a
data structure typically in a database???

Either you unravel it into a sequence of fields, or you serialiase it
and store it as a BLOB.
 
M

Marco Schmidt

Ike:
I have a hashmap (or an arraylist), what kind of data type would I specify
this as in creating it's column in a MySql table. How do you store such a
data structure typically in a database???

You could create a table of its own for the entries of all hash maps
(assuming that keys and values are all of a type that has a
corresponding SQL type like int or varchar and that the types are the
same for all keys and all values).

This example stores two maps, one with nick name / full name pairs,
one with abbreviation / meaning pairs. All values are strings.

keyvaluepairs
id key value
1 "bob" "Bob Smith"
2 "chris" "Christine Miller"
3 "asap" "as soon as possible"
4 "imho" "in my humble opinion"
5 "cu" "see you"

maps
map_id key_value_id
1 1
1 2
2 3
2 4
2 5

The name map is 1 and the abbrev. map is 2 (map_id). You can use those
keys in your other table to reference a map. Now if you want to have
all keys and values of, say, map 2, you can use a join query statement
over the above two tables to retrieve them.

If you want easy storage of (possibly complex) objects, maybe OODBMS
are more interesting for you:
<http://directory.google.com/Top/Com...se_Management_Systems_-_DBMS/Object-Oriented/>.

Regards,
Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top