MySQL Database design for placing service orders

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default MySQL Database design for placing service orders

    Hi, I recently posted to comp.databases but unfortunately have yet to
    receive a reply. I would like to get the design cracked this weekend so im
    positing here in hope of a response :)

    I am currently designing a simple service orders database. I have played
    around with MySQL a bit but this is the first time I'm using it in anger, I
    have a few design queries to make sure I am implementing the database
    correctly.

    Currently I have a number of tables, the first being the package table
    (lists the different service names - such as small, medium etc). Note in the
    tables I have trimmed a lot of the unnecessary stuff to save space:

    Package Table:
    packageID
    name
    PRIMARY KEY (packageID)

    The package durations table lists the different duartions of packages in
    months, that the customer can select. I don't want duplicate durations for a
    particular package, so I make unique primary key based on the packageID and
    duration:

    Package Durations Table:
    packageID
    duration
    PRIMARY KEY (packageID, duartion)

    Now when customers place an order they will select a package, and will need
    to select a duartion. What's the best way to do this? Either I can have
    packageID and a duration in the orders table, or I can actually give the
    package duartions table a new primary key which is unique to define a
    certain 'package/duration' combination. What's the best way to do this? The
    second way would mean I would only need one field in the orders table to
    store the package duration option. Not sure if this is ok, so I have just
    listed the orders table as I have currently implemented it.

    Orders Table:
    orderID
    customerID
    packageID
    duration
    PRIMARY KEY (orderID)

    I have been using fabFORCE dbdesigner 4 (is excellent). However I have a
    query with regard to when I create relationships in the database editor, it
    creates a lot of primary keys (unless using non-identifying relationships -
    haven't come across these before from my book reading). Using the above
    orders table as an example, it would make all the fields listed there
    primary keys. Is this ok? When I was designing the database by hand I
    created only the orderID as a primary key, and set the customerID, packageID
    and duration as normal fields... not sure if this is design is correct but
    it did work ok. Is it the case of the more primary keys the better so the
    database performance can be increased?

    I have also used foreign keys if the value is derived from another table's
    primary key (in the orders table above, I would set customerID, packageID as
    foreign). I presume MySQL performs some form of optimisation or hashing if
    foreign keys are present in tables? Again, am I using this feature
    correctly?

    If anyone could give me some pointers would be very much appreciated.

    TIA

    Chris



    Chris Morley Guest

  2. Similar Questions and Discussions

    1. MySQL Database not retrieving the full database
      Hi, I am using MySQL and PHP for my repository. It has 500+ records. till now it was displayiing all records in the database, but since from one...
    2. placing new excel copy into formatted In Design CS2 document
      Hello I am trying to place new copy from an excel document into an existing In Design document. I copied and pasted the excel data into a new...
    3. Event orders
      My DataGrid's event handlers looks like: Page_Load() { ...// BREAKPONT PageLoad } Grid_ItemDataBound(...) { switch (e.Item.ItemType): {
    4. Web Service App design opinions
      I would like to hear opinions on Web Service App design in terms of where different developers have placed certain initialization or database...
    5. Form submission re-orders results
      This one's got me stumped. I have a form created in DWMX and when the form is submitted the results are re-ordered. In other words the results for...
  3. #2

    Default Re: MySQL Database design for placing service orders

    "Chris Morley" <g18c@nospam.hotmail.com> wrote in message
    news:tZf_c.1295$Ya2.427@newsfe5-gui.ntli.net...
    > Hi, I recently posted to comp.databases but unfortunately have yet to
    > receive a reply. I would like to get the design cracked this weekend so im
    > positing here in hope of a response :)
    >
    > I am currently designing a simple service orders database. I have played
    > around with MySQL a bit but this is the first time I'm using it in anger,
    I
    > have a few design queries to make sure I am implementing the database
    > correctly.
    >
    > Currently I have a number of tables, the first being the package table
    > (lists the different service names - such as small, medium etc). Note in
    the
    > tables I have trimmed a lot of the unnecessary stuff to save space:
    >
    > Package Table:
    > packageID
    > name
    > PRIMARY KEY (packageID)
    >
    > The package durations table lists the different duartions of packages in
    > months, that the customer can select. I don't want duplicate durations for
    a
    > particular package, so I make unique primary key based on the packageID
    and
    > duration:
    >
    > Package Durations Table:
    > packageID
    > duration
    > PRIMARY KEY (packageID, duartion)
    >
    > Now when customers place an order they will select a package, and will
    need
    > to select a duartion. What's the best way to do this? Either I can have
    > packageID and a duration in the orders table, or I can actually give the
    > package duartions table a new primary key which is unique to define a
    > certain 'package/duration' combination. What's the best way to do this?
    The
    > second way would mean I would only need one field in the orders table to
    > store the package duration option. Not sure if this is ok, so I have just
    > listed the orders table as I have currently implemented it.
    >
    > Orders Table:
    > orderID
    > customerID
    > packageID
    > duration
    > PRIMARY KEY (orderID)
    >
    > I have been using fabFORCE dbdesigner 4 (is excellent). However I have a
    > query with regard to when I create relationships in the database editor,
    it
    > creates a lot of primary keys (unless using non-identifying
    relationships -
    > haven't come across these before from my book reading). Using the above
    > orders table as an example, it would make all the fields listed there
    > primary keys. Is this ok? When I was designing the database by hand I
    > created only the orderID as a primary key, and set the customerID,
    packageID
    > and duration as normal fields... not sure if this is design is correct but
    > it did work ok. Is it the case of the more primary keys the better so the
    > database performance can be increased?
    >
    > I have also used foreign keys if the value is derived from another table's
    > primary key (in the orders table above, I would set customerID, packageID
    as
    > foreign). I presume MySQL performs some form of optimisation or hashing if
    > foreign keys are present in tables? Again, am I using this feature
    > correctly?
    >
    > If anyone could give me some pointers would be very much appreciated.
    >
    > TIA
    >
    > Chris
    >
    Chris,

    DB design is not my forte, but.... how about a customer table, a service
    table, and an orders table. If your service table contains fields for
    maximum and minimum duration (this service only available for 1 month, this
    service only available for minimum 12 months, etc.), then three tables let
    you record your prices, services, duration, customers and orders. Your
    customer table can key off name or number, your service key off a service
    name or service id, and you can set your prices by duration unit (month,
    quarter, year, etc.). This way, you only need a need a primary for each
    table, and can select from the customer and order tables to generate
    billings and reports. The service table is used to generate the order form
    on your page (along with the customer table for repeat customers).

    Customer table
    cust. name Primary (no duplicates)
    cust. add1
    cust. add2
    cust. city
    cust. state
    cust. zip
    cust. tel
    cust. number (optional, increment, could be Primary)

    Service table
    serv. name Primary
    serv. description
    serv. period
    serv. min dur
    serv. max dur
    serv. price per period

    Orders table
    cust. name
    order number Primary, increment
    order date
    order service start date (if different from order date)
    order value ($) (dur & price)
    order serv. name
    order duration
    order status (unbilled, billed, paid, overdue, cancelled, etc.)


    setup - create db, create tables, enter service names, durations, pricing

    generate order page - first, check if existing customer - generate same
    form, but fill in customer info if existing, get any changes in customer
    info that need to be made, standard form for orders - service name,
    description, price per period, periods (values including and between
    serv.min.dur and serv.max.dur) -

    receive data, create or update customer record, create order record.

    new customer - create customer record, enter customer info

    new order - create order record, enter cust name, increment order number,
    enter date, enter serv. name, enter duration, calc value (price * duration)

    generate bills - by customer, all orders not past term and not cancelled and
    not paid

    generate reports - by service (pull orders that match, total revenue,
    average duration, group by month, quarter, year), by customer (pull all
    orders, total by customer, by service), by period (pull orders created
    during period, number of customers, number of orders, average price, total
    revenue), by order status (total orders within status, percentage of paid vs
    overdue, etc.)

    Will that do it for you?

    George


    sma1king Guest

  4. #3

    Default Re: MySQL Database design for placing service orders

    I'm sure you already aware of this. but just in case.
    MySQL - Default structure MyISAM does not support foreign keys. You
    would want to use InnoDB engine instead. InnoDB supports transactions with
    Cascade UPdated / Delete on foreing keys.



    "sma1king" <gking@geking.com> wrote in message
    news:S2o_c.987$x12.551@trnddc05...
    > "Chris Morley" <g18c@nospam.hotmail.com> wrote in message
    > news:tZf_c.1295$Ya2.427@newsfe5-gui.ntli.net...
    >> Hi, I recently posted to comp.databases but unfortunately have yet to
    >> receive a reply. I would like to get the design cracked this weekend so
    >> im
    >> positing here in hope of a response :)
    >>
    >> I am currently designing a simple service orders database. I have played
    >> around with MySQL a bit but this is the first time I'm using it in anger,
    > I
    >> have a few design queries to make sure I am implementing the database
    >> correctly.
    >>
    >> Currently I have a number of tables, the first being the package table
    >> (lists the different service names - such as small, medium etc). Note in
    > the
    >> tables I have trimmed a lot of the unnecessary stuff to save space:
    >>
    >> Package Table:
    >> packageID
    >> name
    >> PRIMARY KEY (packageID)
    >>
    >> The package durations table lists the different duartions of packages in
    >> months, that the customer can select. I don't want duplicate durations
    >> for
    > a
    >> particular package, so I make unique primary key based on the packageID
    > and
    >> duration:
    >>
    >> Package Durations Table:
    >> packageID
    >> duration
    >> PRIMARY KEY (packageID, duartion)
    >>
    >> Now when customers place an order they will select a package, and will
    > need
    >> to select a duartion. What's the best way to do this? Either I can have
    >> packageID and a duration in the orders table, or I can actually give the
    >> package duartions table a new primary key which is unique to define a
    >> certain 'package/duration' combination. What's the best way to do this?
    > The
    >> second way would mean I would only need one field in the orders table to
    >> store the package duration option. Not sure if this is ok, so I have just
    >> listed the orders table as I have currently implemented it.
    >>
    >> Orders Table:
    >> orderID
    >> customerID
    >> packageID
    >> duration
    >> PRIMARY KEY (orderID)
    >>
    >> I have been using fabFORCE dbdesigner 4 (is excellent). However I have a
    >> query with regard to when I create relationships in the database editor,
    > it
    >> creates a lot of primary keys (unless using non-identifying
    > relationships -
    >> haven't come across these before from my book reading). Using the above
    >> orders table as an example, it would make all the fields listed there
    >> primary keys. Is this ok? When I was designing the database by hand I
    >> created only the orderID as a primary key, and set the customerID,
    > packageID
    >> and duration as normal fields... not sure if this is design is correct
    >> but
    >> it did work ok. Is it the case of the more primary keys the better so the
    >> database performance can be increased?
    >>
    >> I have also used foreign keys if the value is derived from another
    >> table's
    >> primary key (in the orders table above, I would set customerID, packageID
    > as
    >> foreign). I presume MySQL performs some form of optimisation or hashing
    >> if
    >> foreign keys are present in tables? Again, am I using this feature
    >> correctly?
    >>
    >> If anyone could give me some pointers would be very much appreciated.
    >>
    >> TIA
    >>
    >> Chris
    >>
    > Chris,
    >
    > DB design is not my forte, but.... how about a customer table, a service
    > table, and an orders table. If your service table contains fields for
    > maximum and minimum duration (this service only available for 1 month,
    > this
    > service only available for minimum 12 months, etc.), then three tables let
    > you record your prices, services, duration, customers and orders. Your
    > customer table can key off name or number, your service key off a service
    > name or service id, and you can set your prices by duration unit (month,
    > quarter, year, etc.). This way, you only need a need a primary for each
    > table, and can select from the customer and order tables to generate
    > billings and reports. The service table is used to generate the order
    > form
    > on your page (along with the customer table for repeat customers).
    >
    > Customer table
    > cust. name Primary (no duplicates)
    > cust. add1
    > cust. add2
    > cust. city
    > cust. state
    > cust. zip
    > cust. tel
    > cust. number (optional, increment, could be Primary)
    >
    > Service table
    > serv. name Primary
    > serv. description
    > serv. period
    > serv. min dur
    > serv. max dur
    > serv. price per period
    >
    > Orders table
    > cust. name
    > order number Primary, increment
    > order date
    > order service start date (if different from order date)
    > order value ($) (dur & price)
    > order serv. name
    > order duration
    > order status (unbilled, billed, paid, overdue, cancelled, etc.)
    >
    >
    > setup - create db, create tables, enter service names, durations, pricing
    >
    > generate order page - first, check if existing customer - generate same
    > form, but fill in customer info if existing, get any changes in customer
    > info that need to be made, standard form for orders - service name,
    > description, price per period, periods (values including and between
    > serv.min.dur and serv.max.dur) -
    >
    > receive data, create or update customer record, create order record.
    >
    > new customer - create customer record, enter customer info
    >
    > new order - create order record, enter cust name, increment order number,
    > enter date, enter serv. name, enter duration, calc value (price *
    > duration)
    >
    > generate bills - by customer, all orders not past term and not cancelled
    > and
    > not paid
    >
    > generate reports - by service (pull orders that match, total revenue,
    > average duration, group by month, quarter, year), by customer (pull all
    > orders, total by customer, by service), by period (pull orders created
    > during period, number of customers, number of orders, average price, total
    > revenue), by order status (total orders within status, percentage of paid
    > vs
    > overdue, etc.)
    >
    > Will that do it for you?
    >
    > George
    >
    >

    Ninjaboy Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139