Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 30th, 2003, 02:22 AM
leo_dawson leo_dawson is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 5 leo_dawson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
database search question

hi everyone

i have a question. I have a site where users can select their top 10 skills. Basically the form consists of 10 different check boxes and the users can check as many as they want where each check box corresponds to a particular skill.

Now this is my question. After the users select their skills, should i get the check box values and concatenate them into one string seperated by comma's and store that one string in one text field of the database or should i have 10 different columns in the database to store these values. Is this a good practice.

Now based on these values, I need to perform a keyword search to find a user of a particular skill.

What I was planning to do is to store all the skills of a particular user as one string (seperated by comma) in the database. And while searching by keyword , retrieve this string stored in the database and check if the entered keyword exists in that string or not.

I would really appreciate any advice on the same. Is this the best way to do it. The programming language i'm using is java and the database is mysql.

thanks
leo

Reply With Quote
  #2  
Old July 30th, 2003, 04:07 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I have been working in SQL for only six months, so please take my recommendation only as a recommendation and not as the be-all end-all

I would not suggest using 10 columns for each of the skills. What happens when you want to add another skill? And it's going to be difficult (and slow) searching for one skill in 10 columns.

Neither would I suggest using only one column and throwing everything in there. First prob is: What happens if their are commas within the skill. Then the skill will show as two skills. And I don't really think it's good practise (then you might as well use a text file instead of a databse).

What I would suggest is using two table (well actually three, but I assume that you already have a table that stores the users with some sort of unique identifier with every user).

The first table will hold a skill id, and a skill description. Your page can then just run through the table, and find display all the descriptions. This is very quick to develop (the web page), easy to create, and easy to add more skills should you need to. An example of the table:
siSkillId vcDescription
1 Catching bugs
2 Eating bugs
3 Watching bugs
4 Killing bugs

The second table will also have only two columns, one for the userId, and the other for the skill ID. Since one user can have more than one record in this table, this takes up a bit more space, but I think the advantages are worth it. It will be easier to search through it, easy to add another skill for a user. You can even add another column to show the order of the skills (in which one the user is best)
example of the table:
siUserId siSkillId
1 1
1 2
1 3
1 4
2 3
4 1
4 2

Reply With Quote
  #3  
Old July 30th, 2003, 09:07 PM
leo_dawson leo_dawson is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 5 leo_dawson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks

hey
thanks for ur advice. I really appreciate your time. I'll look into ur idea and see what best suits my needs. But it was good to learn abt your idea...thanks again
leo

Reply With Quote
  #4  
Old July 30th, 2003, 11:50 PM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Glad I could help. It's a shame nobody else replied. I would have liked to learn more idees as well (South Africa is usually a bit behind on new idees ).

Oh yes, I never said this, but between your two idees, I'll go for the throwing everything in one column thing. I think the advantages of faster search time will more than make up for the more development it's going to cost you.

Reply With Quote
  #5  
Old July 31st, 2003, 10:09 PM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
5 years of db development says...

that the idea of having multiple tables is the best idea. After all, you are working in a relational database, aren't you? Besides, with proper indexing (you were planning on indexing your columns for rapid retrieval, right?) and the use of integer values instead of strings, you should be able to write a stored procedure to retrieve datasets that specifically match your query, format it for display, and dump it into a result set for processing in your CGI simply, easily and very quickly. My favorite is to do most of the formatting in the procedure and have rather generic display routines in the CGI, that way I can make changes willy nilly and never touch production code.

BTW: If your database starts to get really big (I have worked with tables with 15 million+ rows and have millisecond return times) you can begin to use temporary tables in your procedures to improve your performance even more (I have been able to get up to 2 orders of magnitude performance increases by using temp tables). My experience is mostly with Sybase and MSSqlserver, but the same approach should work in any (real) database.

Good luck!
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > database search question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway