sql - Car parking reservation availability query with date and time -


I am implementing a car parking reservation system in which a user maintains a parking space.

Reservation Table Column -------------- Parking SpaceIID Vehicle IID User Id Starttime and Timeout Endtime

Space table

  column -------- avialablespaces noOfBookings   < P> User can check the available parking space with the parameter  Start date ,  start time ,  expiration date ,  end time < / code>.  

If avialablespaces == NoOfBookings then parking space is not available.

To find out if there is a parking space available between startdate, start-up and enddate, end time, what is the logic?

By asking for parking spaces, you can get the number of parking available at a certain time for which booking Time is not present, where at the time your given time starts S or ends.

BTW: Why do you split dates and time in your table? The only reason for this is that I can think that there is a possibility of being one without each other, eg. There is no time specified by one day (and no default time is related) If this is the case then you have to consider it in the selection above. If not, then you should change your table design.

Edit: Your reservation table has a parking space ID, I think there is a parking space with a record per parking space. Here is a possible statement: It depends on the DBMS how the statement looks like I use the extra work of Oracle here to combine the date and time for easy comparison. It is always a kind of arena that it can work with different date and time zones and if there is one of them - which will be the only sensible reason for division - it is even more complex. You have to adjust the statement accordingly.

  Select parking spaces where it is not present (select * from * reservation * r.parkingspaceid = s.id and ((additional time (start, startup)> gt; = addtime (R.Startdetter, R. StartTime) and AdTime (: StartDate, Starttime) & AdTime (R.AndDiet, R.AndTime)) or (Adetime (Ended, Endime)> AdTime (R. Start Dat, R. Starttime) and AdTime (: Ended, End-time) & amp; AdTime (R.AndDiet, R & D));    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -