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 flowersI 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 oth开发者_开发技巧er kind of file)?
Thanks everyone!
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 this tutorial 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 detailsroles
-- all the available rolestasks
-- tasks that each role is assigned,role
andtask
has one to many relationship (see the FK?)people_roles
-- this is a link table that makes may-to-many relation ship betweenpeople
androles
, so that a gardener can be act as a cook. If you wish to assign so.
Hope this helps.
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, CakePHP would by my recommendation based on it's powerful auto-magic CRUD (Create, Read, Update, Delete - something else to read up on :) ).
精彩评论