如何构建一个简单的数据库
我想构建一个具有以下性质的数据库:
有不同类型的人,每个人都做很多工作,例如:
清洁工:清洁厕所,清洁厨房
女佣:洗衣服,做早餐,做午餐
园丁:种花、浇花
我还将有一个 MySQL 数据库,其中包含所有清洁工、女佣、园丁等。用户将他需要的工作写入 HTML 表单,然后 PHP 文件将确定谁来做所需的工作,然后选择最适合该工作的人。
如何构建上述数据库?我是像上面那样做吗?
PHP 如何“将它们组合在一起”?我必须使用数组吗?
我应该将该数据库直接放入 PHP 代码中还是单独的文本文件(或其他类型的文件)中?
谢谢大家!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如另一篇文章中所指出的,在深入研究复杂的事物之前,您需要学习基础知识。网上有很多教程,很容易理解和入门。
您可以从本教程开始,掌握如何使用 MySQL 和 PHP,然后您可以将以下架构用于您的 Web 应用程序。
people
-- 所有员工/人员及其详细信息roles
-- 所有可用角色tasks
-- 每个角色分配的任务,role
和task
具有一对多关系(请参阅FK?)people_roles
-- 这是一个链接表,在people
和roles
之间建立多对多关系,以便园丁可以充当做饭。如果您希望这样分配。希望这有帮助。
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
-- 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.
在你会跑之前,你需要先学会走路。
我会首先学习一些基本的 PHP/MySQL 教程,让自己熟悉数据操作的基础知识。然后也许为了加快生产使用框架,CakePHP 是我的推荐,基于它强大的自动魔法 CRUD(创建、阅读、更新、删除 - 还有其他需要阅读的内容:))。
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 :) ).