General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Laplink Gold 2008 - $15 Off with Coupon Code CJM9NE
  #1  
Old August 29th, 2002, 07:24 PM
zammee zammee is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 3 zammee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Multiple users per event

Hi,

I'd like some advice on the design of a MySQL database that details an event and details about this event. Basically I have a table which lists time,date,location etc, but for each event recorded in this table there are up to 15 or so participants.

What is the best way of storing and retrieving this data?

Adding a field per participant to the table would contravene normalisation rules, but then if the participants are listed in another table, with a reference to the first table, how do you then doa SELECT to retrieve information about 1 event and all the participants in one single query?

Any information much appreciate, thanks,

Zammee

Reply With Quote
  #2  
Old August 30th, 2002, 04:06 PM
Brian Rosner Brian Rosner is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Denver, CO
Posts: 34 Brian Rosner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Brian Rosner Send a message via AIM to Brian Rosner Send a message via Yahoo to Brian Rosner
Your solution

I'd say the best way of accomplishing that task will be having one field that is named participants and it will store each person that can be delimited by a certain characater or characaters. For example: John Doe|Mary Jane|Bill Gates (the | is your delimiter) You could use anything, but don't use a space if you store people by full name.

Then you select that event from the table and then you will have your server side language break it up. With PHP you can use either explode() or split(). Using split() will allow you to use regular expressions.

Or you can have a completely different table that stores the people by event ID. And you select the people involved in that event by the event ID using MySQL's WHERE clause. Hope this helps.

Last edited by Brian Rosner : August 30th, 2002 at 04:10 PM.

Reply With Quote
  #3  
Old August 30th, 2002, 05:30 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Re: Multiple users per event

Quote:
Originally posted by zammee
if the participants are listed in another table, with a reference to the first table, how do you then doa SELECT to retrieve information about 1 event and all the participants in one single query?

Any information much appreciate, thanks,

Zammee


You've got the right idea... The way you would select both tables is like this:

SELECT events.name, users.name WHERE users.eventId = events.eventId

That's just an idea... I'm not sure what you're table/field names are... But if you're confused and need help, let me know!
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #4  
Old August 31st, 2002, 10:24 AM
zammee zammee is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 3 zammee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Frankie,

What I'd like to achieve is to retrieve
PHP Code:
 event.name 
and all the associated
PHP Code:
 users.name 
s in one result, so in PHP all the information for one event, including all the users and the event details, would be stored in an array in the usual fashion.

A crude way of performing this might be
PHP Code:
 SELECT event.name,u1.nameu2.nameu3.name etc FROM event,users AS u1users AS u2users AS u3 etc WHERE u1.id=event.id AND u2.id=event.id AND u3.event=u3 etc 
but clearly this isn't a very good way of doing things!

Kind regards,

zammee

Reply With Quote
  #5  
Old August 31st, 2002, 01:22 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
If I understand correctly, try this:


SELECT event.name, users.name WHERE users.eventid = event.eventid

That will display all the users that correspond to a specific event.

Reply With Quote
  #6  
Old September 1st, 2002, 03:43 PM
zammee zammee is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 3 zammee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Frank,

Sorry not to have made myself a bit clearer :-

your method works of course, but you get one result row for each combination of event/user, so 2 events with 10 and 5 users each respectively would give 15 result rows.

What I'd ideally like is to have one result row per event, each row including all the users as well as the name of the event, so that for the numbers above there would be 2 result rows, although I don't know how the columns would look - this is where I'm stuck

This might not be a feasible proposition though, just let me know if I'm trying to do the impossible!!
Thanks very much,

zammee

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Multiple users per event


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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