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

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:
  #1  
Old June 17th, 2003, 06:39 AM
aspwiz aspwiz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Eastbourne, UK
Posts: 1 aspwiz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unsure about Schema....

Hi...

Let me pose a senario....

I am designing a database for a hotel website....

I am unsure as to how to store bookings and search availability.

do i use a table with every date from jan 1st to dec 31st and then have a checkbox available in each row for each room?? I'm so damn unsure about this one....

Many thanks for any help offered.

Regards,

Rob.

Reply With Quote
  #2  
Old June 17th, 2003, 08:53 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
You would create a bookings table, which might look something like:

bookingid INT PK (AUTO INCREMENT)
roomnum INT
startdate SMALLDATETIME (or just DATE in Access)
enddate SMALLDATETIME (or just DATE in Access)
customerid INT FK
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old August 5th, 2003, 03:06 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
building on stumpy

you could opt to create a room table
ROOMID int (PK)
TYPEID smallint {FK}

and a Room type table
TYPEID smallint (PK)
characteristics varchar(100) -- like (non)smoking, king size bed, double/single room etc..

availability for a room non-reserved room for a specific type
Code:
DECLARE @typeid smallint,  @checkdate smalldatetime
SET @typeid = 1
SET @checkdate = GETDATE()

SELECT COUNT(*) FROM room WHERE TYPEID = @typeid 
AND NOT ROOMID IN (
SELECT ROOMID FROM bookings WHERE ROOMID IN 
  (SELECT ROOMID FROM room where TYPEID = @typeid)
AND ( DATEDIFF(d, startdate, @checkdate) <=0 AND 
DATEDIFF(d, enddate, @checkdate) >=0 )
)


Have not tested this select statement, but you get the picture. Not entirely sure about the DATEDIFFs....

Hope this helps
__________________
- Rogier Doekes

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Unsure about Schema....


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