SunQuest
           MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old January 25th, 2000, 01:12 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to yoshi
Hello,
I am attempting to create my first mySQL database (a very large one at that). I am not sure how to create it in the most efficient way, however.
I have many fields called "group". Each "group" contains a number of each of "name", "URL", and "rating" fields (see picture below). Should I create many tables, each one a group, or should I somehow combine them all into one very large table? Is there a way to create arrays in mySQL?

Thank you for any help in advance..
Josh
CATGOLF888@aol.com

====================================
Each group looks like:

Group
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating

Group 2
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating
Name URL Rating

and so on...

Reply With Quote
  #2  
Old January 25th, 2000, 02:41 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
It all depends on the data you're dancing with...post some examples of the values to be stored to give everyone a better idea of where you're coming from.


Reply With Quote
  #3  
Old January 25th, 2000, 07:39 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to yoshi
Here's an example (the data will hopefully become a list of links):

Group: Search Engines
(NAME) (RATING) (URL)
Yahoo 5 http://www.yahoo.com
HotBot 4.5 http://www.hotbot.com
Excite 4.5 http://www.excite.com
Altavista 4 http://www.altavista.com
Lycos 4 http://www.lycos.com

Group: Email Providers
(NAME) (RATING) (URL)
Hotmail 5 http://www.hotmail.com
Yahoo 5 http://www.yahoo.com
Bigfoot 4 http://www.bigfoot.com
Zensearch 4 http://www.zensearch.com
Mail 4 http://www.mail.com

What would be the best way to database a large number of groups???

Reply With Quote
  #4  
Old January 26th, 2000, 09:24 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
OK, so from your examples, it looks like the group and url columns should be a composite primary key.

Try something like

create table table_name(
Group varchar(25) not null,
SiteName varchar(25) not null,
Rating decimal(5,1),
URL varchar(50),
primary key(Group, SiteName));

This will ensure that there are no duplicate Group-Sitename pairs in the table. You could put a primary key across all four columns if you wanted to, but the fewer columns in a composite index, the better performance (generally)

Later

Reply With Quote
  #5  
Old January 26th, 2000, 09:25 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Sorry about that, Group and SiteName should be the composite primary key

Reply With Quote
  #6  
Old January 26th, 2000, 02:56 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to yoshi
Thanks. Would this be the most efficient way if I had more than 100 groups (1 per table)?? Why do I need the key?

Thank you again.
Josh

Reply With Quote
  #7  
Old January 26th, 2000, 03:27 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I was assuming (maybe incorrectly) that you would have all the data in one large table and this would work as long as each group name is unique (Email Providers, Search Engines, Portals) of the 100 that you have. The composite primary key is necessary so that you don't have duplicate entries i.e,

msyql>insert into table_name values(
'Email Providers', 'Yahoo', 5, 'http://www.yahoo.com');
// this insert statement is OK

mysql>insert into table_name values('Search Engines', 'Yahoo', 5, 'http://www.yahoo.com');
// this insert statement would be OK

mysql>insert into table_name values('Email Providers', 'Yahoo', 4.5, 'http://www.yahoo.com');
// ERROR - violates composite primary key constraint GroupName-SiteName 'Email Providers-Yahoo' already exists -> just use UPDATE to change info in this row

I tend to think this table structure would be much more concise and manageable than having 100 different tables based on each group name

Reply With Quote
  #8  
Old January 26th, 2000, 06:17 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to yoshi
Thanks so much for your help...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > help creating a mySQL database (!!NEW!!)


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 6 hosted by Hostway