如何构建一个简单的数据库

发布于 2024-10-29 20:44:39 字数 338 浏览 0 评论 0原文

我想构建一个具有以下性质的数据库:

有不同类型的人,每个人都做很多工作,例如:

清洁工:清洁厕所,清洁厨房
女佣:洗衣服,做早餐,做午餐
园丁:种花、浇花

我还将有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深者入戏 2024-11-05 20:44:39

正如另一篇文章中所指出的,在深入研究复杂的事物之前,您需要学习基础知识。网上有很多教程,很容易理解和入门。

您可以从本教程开始,掌握如何使用 MySQL 和 PHP,然后您可以将以下架构用于您的 Web 应用程序。

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 -- 所有员工/人员及其详细信息

  • roles -- 所有可用角色

  • tasks -- 每个角色分配的任务,roletask 具有一对多关系(请参阅FK?)

  • people_roles -- 这是一个链接表,在 peopleroles 之间建立多对多关系,以便园丁可以充当做饭。如果您希望这样分配。

希望这有帮助。

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 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.

停顿的约定 2024-11-05 20:44:39

在你会跑之前,你需要先学会走路。

我会首先学习一些基本的 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 :) ).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文