mysql - Designing my first database schema: suggestion needed -


this first database schema design. trying develop small web application department used food cost management. , doing learning purpose.

how food cost management works in department:

  1. total members: 15
  2. one admin keep record of cost. update database on daily basis.
  3. each member can order once day. if has guest on specific day can order multiple number of meal.
  4. usually members pay bill week or 2 in advance.
  5. one or 2 persons responsible bringing food outside , don't need pay lunch. transportation cost given them. food cost+ transportation cost distributed equally other 15 members expenses.

database queries:

from admin perspective:

  1. he manage/add daily order. (table: orders)
  2. he add payments members credited against respective member's "balance" (table: payments)
  3. he able see overview of members' order/cost history , current balance in chart 1 month @ time.
  4. if member has negative balance or less specific amount of money, notified admin dashboard.

from member perspective:

  1. he able see current balance , order/cost history last 1 month @ time.
  2. he able see last x number of payment history made.

based on queries mentioned above tried design database schema looks diagram below:

database schema diagram

elaboration of attributes:

eplatenum: number of plate of food brought besides number of plate ordered.

eplatecost: cost plate of food. cost distributed equally among 15members individual cost.

epersonnum & epersoncost: number of person involved in bringing food , total cost. cost distributed equally among 15members individual cost.

transcost: transportation cost. cost distributed equally among 15members individual cost.

questions:

  1. what mistakes have made , how can overcome them?

  2. for dailylist table have used "date" primary key.is ok use date primary key? if not ok, can primary key here instead?

  3. when going populate chart overview 30 months cost/order history database query huge assume. approach should take optimize query?

i looking forward getting suggestions on improving database schema. please me correcting design mistakes , overcome them. thank patience.

my first impression:

  1. i think payment should related order (because user pays specific order).
  2. i don't know dailylist is, if there may more 2 same date (and can image may be) shouldn't use primari key.
  3. password should encoded e.g. sha (so varchar 15 less).

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -