8 Replies - 1718 Views - Last Post: 02 March 2013 - 12:23 PM Rate Topic: -----

#1 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Storing logic for discount module

Posted 02 March 2013 - 09:15 AM

Hi guys,

I'm writing a discount module for my booking system and was looking for some advice on how others would store this data in the database.

I plan give the users the following form:

Drop Down: number of nights, number of guests
Drop Down: less than, greater than, equal to, between
Drop down: 1,2,3,4,5....
Drop down (only shown if between is selected): 1,2,3,4,5...

I look forward to hearing your views :)

Thanks,

Tom

Is This A Good Question/Topic? 0
  • +

Replies To: Storing logic for discount module

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,131
  • Joined: 12-June 08

Re: Storing logic for discount module

Posted 02 March 2013 - 10:20 AM

Store what in the database? That seems like search criteria that wouldn't necessarily be stored.
Was This Post Helpful? 0
  • +
  • -

#3 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Storing logic for discount module

Posted 02 March 2013 - 10:29 AM

Hi modi,

Store the form values in the database. The form is to allow the admin to set the criteria that the booking has to qualify for to receive the discount.

It will probably end up being more complex but I just wanted to get ideas to how others would store this in the database with a simplified version.

Thanks,

Tom
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,131
  • Joined: 12-June 08

Re: Storing logic for discount module

Posted 02 March 2013 - 10:48 AM

I see.. well I would guess a max and min column for each type would be sufficient, right?

min number of nights,
max number of nights,

min number of guests
max number of guests
... etc
Was This Post Helpful? 1
  • +
  • -

#5 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Storing logic for discount module

Posted 02 March 2013 - 11:10 AM

Okay thanks modi and how would you store the less than, greater than etc.. Variables?

Thanks,

Tom
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,131
  • Joined: 12-June 08

Re: Storing logic for discount module

Posted 02 March 2013 - 11:13 AM

You wouldn't. First it doesn't make sense in the context of a discount where there, almost always, is a hard line drawn on either a minimum or a maximum value. Plus that is all more or less implied by having a max and min value, right? A row with a max value and no min value for occupants would imply a range of 1 occupant to the max value. A row with a min value and no max value would imply min to infinite.. etc.
Was This Post Helpful? 0
  • +
  • -

#7 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Storing logic for discount module

Posted 02 March 2013 - 11:56 AM

It's very restrictive that's the only thing what if I were to add a new variable e.g. The "the booking was made" to the first column.

I was thinking something more like

Variable | Expression | Condition | Condition End

The variable being "length of stay" or "number of people" etc.
Expression being "greater than" or "less than" etc.
Condition being 1 or 2 etc
Condition End used when the expression is between.

What do you think?

This post has been edited by tommyflint: 02 March 2013 - 12:03 PM

Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,131
  • Joined: 12-June 08

Re: Storing logic for discount module

Posted 02 March 2013 - 12:10 PM

What is 'very restrictive'?

Over all that sounds like a bad design. It is convoluted and not effective.
Was This Post Helpful? 0
  • +
  • -

#9 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Storing logic for discount module

Posted 02 March 2013 - 12:23 PM

In the way I just explained if I add a new variable I have to add new columns.

Can you explain how my option is "not effective"?

Maybe I'm not explaining myself very well the idea of this is so the owner can set certain discount criteria e.g. Give 10 discount when the number of nights is greater than 2... Give 20 discount when the number of people is less than 4.... Give 30 discount when the the booking is made equal to 10 days before etc...

I very much appreciate your feedback modi... This is exactly the reason I started this post to get other people's opinion and positive critism :)

Thanks,

Tom
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1