User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 402,911 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,093 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 321 | Replies: 2
Reply
Join Date: Jul 2008
Posts: 4
Reputation: ncognito66 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ncognito66 ncognito66 is offline Offline
Newbie Poster

Help with Database Query...

  #1  
Jul 17th, 2008
Hello all:

I'm currently building a website for a radio station and I want to setup a programming lineup. The fields I'm using are:

ID
Title
Dayofweek (Show Day)
Timeslot (Show Time)
AMPM (AM or PM)
Description
Name (Host Name)
Bio (Host Bio)
Photo (Host Photo)

I set these all up as TEXT as I wasn't sure how to do it correctly.

I want to be able to make a schedule listing the shows by Day of Week and then by Time, and I also want to make a box showing the current program on the air.

Any ideas for a newbie????

Thanks all!

Alan
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Adelaide, South Australia
Posts: 364
Reputation: darkagn will become famous soon enough darkagn will become famous soon enough 
Rep Power: 3
Solved Threads: 42
darkagn's Avatar
darkagn darkagn is offline Offline
Posting Whiz

Re: Help with Database Query...

  #2  
Jul 17th, 2008
Couple of quick points:

ID fields should never be a text field. Use Unsigned INT or something similar. This helps efficiency and referential integrity of your tables.
Think about maybe consolidating the three columns Dayofweek, Timeslot and AMPM into one column, TimeOfDay, and making it a smalldatetime field, which is much nicer to work with than a straight text for dates and times.
Photo - you have a couple of choices, either this is a filename to the image of a photo, or better still make this a varbinary field and store the image's binary data directly in the database.

Ok, that said, for an SQL statement to list all shows by day and time, something like
  1. SELECT * FROM TableName
  2. ORDER BY TimeOfDay ASC
should do for a start. You can always refine this statement with a WHERE clause to limit to a specific date if you want:
  1. SELECT * FROM TableName
  2. WHERE TimeOfDay > '2008-07-17 00:00:00'
  3. AND TimeOfDay < '2008-07-17 23:59:59'
  4. ORDER BY TimeOfDay ASC

Hope this helps
darkagn
The answer is 42.
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: ncognito66 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ncognito66 ncognito66 is offline Offline
Newbie Poster
  #3  
Jul 19th, 2008
Originally Posted by darkagn View Post
Couple of quick points:

ID fields should never be a text field. Use Unsigned INT or something similar. This helps efficiency and referential integrity of your tables.

Think about maybe consolidating the three columns Dayofweek, Timeslot and AMPM into one column, TimeOfDay, and making it a smalldatetime field, which is much nicer to work with than a straight text for dates and times.
Photo - you have a couple of choices, either this is a filename to the image of a photo, or better still make this a varbinary field and store the image's binary data directly in the database.

Ok, that said, for an SQL statement to list all shows by day and time, something like
  1. SELECT * FROM TableName
  2. ORDER BY TimeOfDay ASC
should do for a start. You can always refine this statement with a WHERE clause to limit to a specific date if you want:
  1. SELECT * FROM TableName
  2. WHERE TimeOfDay > '2008-07-17 00:00:00'
  3. AND TimeOfDay < '2008-07-17 23:59:59'
  4. ORDER BY TimeOfDay ASC

Hope this helps
darkagn


Yes, the ID field is an INT,auto-increment,but the rest are TEXT.

I was trying to make the form easy for the programming director to use, therefore the 3 different columns. I've never played with DATETIME items much, so I'm not sure how to combine them as you say.

What the query would have to do is check the current day of week and limit results to that day, then check current time and show the programming for the last timeslot. (Example: Monday at 2:17 PM would return listing for the program that started at 2:00PM on Mondays).

Photos I'm simply inputting file anem and manually uploaded to the server. I've never stored binary data as you say and unsure how to do it.

Thanks for your help!

Alan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 3:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC