How would I structure database the best?

How to structure a simple database

  • I would like to construct a database of the following nature: There are different types of people, and each person does many jobs, example: cleaner: clean toilet, clean kitchen maid: do laundry, cook breakfast, cook lunch gardener: plant flowers, water flowers I will also have a MySQL database with all of the cleaners, maids, gardeners, etc. The user will write which job he needs into an HTML form and then the PHP file will determine who does the desired job and then select the most appropriate person for the job. How do I structure the above database? Do I do it just as I did above? How does PHP "put them together"? Must I use arrays? Should I put this database directly into the PHP code or in a separate text file (or other kind of file)? Thanks everyone!

  • Answer:

    As indicated in the other post, you need to learn basics before you dive into something complicated. There are ample tutorials on web which are easy to understands and get started with. You may start with http://www.blazonry.com/scripting/linksdb/start.php to get a grasp of working with MySQL and PHP, and then you can use the following schema for your web-application. people people_id (PK) name roles role_id (PK) role_name tasks task_id (PK) role_id (FK) task_desc people_roles pr_id (PK) people_id (FK) role_id (FK) people -- all the employees/people and their details roles -- all the available roles tasks -- tasks that each role is assigned, role and task has one to many relationship (see the FK?) people_roles -- this is a link table that makes may-to-many relation ship between people and roles, so that a gardener can be act as a cook. If you wish to assign so. Hope this helps.

James at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

You need to learn to walk before you can run. I would do some basic PHP/MySQL tutorials first to get yourself familiar with the very basics of data manipulation. Then maybe to speed up production use a framework, http://www.cakephp.org would by my recommendation based on it's powerful auto-magic CRUD (Create, Read, Update, Delete - something else to read up on :) ).

Dunhamzzz

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.