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:
  #1  
Old March 22nd, 2004, 09:43 AM
kohl kohl is offline
Java and Web Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: South United Kingdom
Posts: 61 kohl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Dates in databases help ?

Well ive been reading up and id just like to pose the problem.

i want to hold information about bookings in a database.
they will make a choice about what date they wish to book from and then the type of booking either 3-4 or 5 days.

So they will pick these values , and what i was to do is then create a page that will create some sort of timetable as it were to show the availablility over say a month.

am i going to have to test every date with dates in between calculated dates. (if that makes sense)

i can hardly store every date that is booked in a certain booking so how am i going to test each booking for availability .

im so confused with the idea and how other people have stored dates in such ways.(im using mysql)
If anyone could help (de)confuse me.

Reply With Quote
  #2  
Old March 22nd, 2004, 09:49 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,235 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 15 h 57 m 34 sec
Reputation Power: 1054
for simplicity, store the first and last date of a booking, even if it's the same date (for a 1-day booking)

this allows BETWEEN syntax in your sql
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
  #3  
Old March 22nd, 2004, 10:26 AM
kohl kohl is offline
Java and Web Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: South United Kingdom
Posts: 61 kohl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
so in theory i could :

Loop through the database getting bookings in the current month.
Then display in date order the bookings and if a booking does not exist for a certain day or days display its availability using this between statement.

Reply With Quote
  #4  
Old March 22nd, 2004, 11:09 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,235 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 15 h 57 m 34 sec
Reputation Power: 1054
you could, i guess

i wouldn't

to start off, sql doesn't loop

you get a single result set, i.e. a table, returned from the SELECT

how the database does it (looping, or the equivalent) is not your primary concern

what you want is to return all bookings where the given date is between the start and end booking dates

if you get any results back, then that given date is already booked

if you don't, it's available

easy, eh?

Reply With Quote
  #5  
Old March 23rd, 2004, 11:02 AM
kohl kohl is offline
Java and Web Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: South United Kingdom
Posts: 61 kohl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
easy indeed if im using sql but i have to use JDO (java) and have no idea how i could do exactly the same thing using it .

JDOQL is ment to be crap to do this sort of thing....

Reply With Quote
  #6  
Old April 14th, 2004, 11:43 AM
tyndyll tyndyll is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Belfast
Posts: 78 tyndyll User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 33 m 18 sec
Reputation Power: 7
hi all,

i am currently completing a similar project for recording the bookings at a YMCA. they have a limited number of beds and so need to keep a check on whos coming in and out to prevent double bookings

my database structure is like this

bookingID
date_in
date_out
accomodation /* allocated a room */
.
.
(other personal name, address type stuff...)

when i a new booking is coming in i will search for bookings between the new bookings date of arrival and date of departure.

i.e. SELECT * WHERE date_in > selected_arrival_date AND date_out < selected_leaving_date

(my greater and less thans may be the wrong way round) This allows me to see everyone in between those two dates. If the number of rows returned is greater than the constant NO_OF_BEDS then they can't be booked in. I'm doing this in PHP but at the end of the day the theory is the same

This is my 2cents, but it bothers me that i can't tighten it down at the database level, only in the application. If someone can come up with a better method please let me know

Thanks

Tyndyll

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Dates in databases help ?


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 1 hosted by Hostway
Stay green...Green IT