If I remember well some database theory, you are using a denormalized database: you have a field in the USER table which actually contains a list of user hobbies:
Anonymous Monk|89|1:2:3
From a database-design point of view I think you should have 3 tables:
USERS(USER_ID, NAME)
HOBBIES(HOBBY_ID, DESCRIPTION)
USER_HOBBIES(USER_ID, HOBBY_ID)
The table USER_HOBBIES describes the relationship between USERS and HOBBIES which is a many to many relationship.
If you had this db structure, and your current user is for example "Anonymous Monk", whose USER_ID is 89, you can retrieve his hobbies with a select performing a join:
SELECT HOBBIES.DESCRIPTION
FROM USER_HOBBIES, HOBBIES
WHERE USER_HOBBIES.USER_ID = 23
AND USER_HOBBIES.HOBBY_ID = HOBBIES.HOBBY_ID
With this approach you don't need the hobbies array, and you don't need to perform any split from your perl script: you move the logic into the db and let the db engine do the work.
You may want to evaluate which approach gives the best performance: the denormalized database with perl performing much work, or the db with one more table and the join query.
IMHO db engines perform these tasks very well, and AFAIK denormalization is mainly used when designing datawarehouses (which are not actually 'relational' databases)
I hope this may help
marcos
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.