Database design help

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Hello,

I need to create a program that allows people to register for home delivery of their shopping. I have a rough idea of how to do it but I am stuck on one part. The problem is that there can only be a certain number of deliveries per day i.e. 18. How do I limit the number to 18 within a database? I really have no idea how to do this so any help would be great.

The baasic idea will be that a customer will have a button to press which will be for home delivery, once they have pressed the button the number of available delivery slots will be reduced by 1.

Thanks
Levy
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
Reduced or increased ... really doesn't matter ;)



Ok, make a new table and add the fields "deliveries", "deliveriesDate" and "UserID". Each time when user logs in, you will check does certain user have bought something today (if so, then how many times and you will proceed the number to varibale) by checking his/her ID and date.



If yes, but he/she doesn't Exceed permissive shopping times ... then simply update field "deliveries". Otherwise insert new records respectively.



Btw, you can pass "deliveries" to the variable and just proceed when time comes for that.

i.e. in the block where you insert new delivery just insert update block:



VB.NET:
[/color]
[color=black]{…} [/color]
[color=black]UPDATE table Set deliveries = “ & myDeliveries + 1 & “ ..[/color]

[color=black]{…}[/color]
Kind regards ;)
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Ok what if I had a setting where you could change the ammount of deliveries? You wouldn't be able to simply make a table with 18 rows in because you don't know how many there are going to be.
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
if i understand well your question you can add aditional field "defaultDeliveries" in the same table ... by default it's a "18" ... you can change it (update it in any time) later of course. So, to involve it in action you will compare with deliveries ... very simple i guess ... Cheers ;)
 
Last edited:

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
levyuk said:
Ok what if I had a setting where you could change the ammount of deliveries? You wouldn't be able to simply make a table with 18 rows in because you don't know how many there are going to be.
I think we have missunderstood :(

You'll have only one row for each user there ...

probably you have table "orders" or something with records for all deliveries including "dateOfDeliverie" as well.

on load where you check user's Integrity and Authenticity ... check if user have bought something today comparing with Date.Today (i assume you have already provided this). Right after it update "deliveries" field in new table ... and rest of the story is well known i guess ... Cheers ;)
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
I guess what I could do is use a stored procedure to check how many rows are currently in the deliveries table then compare that to the ammount allowed. If it is less than the ammount allowed then it will all another delivery. if not then it will tellthe user no more deliveries for this time slot.
 
Top Bottom