CakePHP 数据库设计指南

发布于 2024-09-19 17:51:18 字数 2251 浏览 14 评论 0原文

我正在使用 CakePHP 框架开发一个应用程序,目前正在设计数据库。我想确保正确设计对象及其关联,以便应用程序性能良好、组织正确、可扩展且可扩展。我将首先详细描述该应用程序,并提出一个对象关系模型。我需要一些最佳实践和 CakePHP 约定方面的指导。请仔细阅读说明,然后回答我的问题。

如果您需要澄清任何内容,请发表评论。

应用程序背景和要求

该应用程序将充当某种专门的 CRM。客户将使用它来跟踪和管理客户、联系人、工作、库存、供应商和机会。客户端当前拥有一个杂乱无章的大型数据库和已损坏的应用程序代码。他们需要使用 CakePHP ORM 和在数据结构之上构建的新应用程序从头开始重建数据库。数据库将建立在MySQL中。应用程序需要通过访问控制列表支持多种用户类型。它需要设计为能够有效扩展,并且以后需要在对象模型之上构建新的应用程序。

建议对象(子项目符号继承自上述对象)

  • 公司 - 客户与客户有业务往来的任何公司
    • 客户 - 客户的客户
    • 承包商 - 与客户签约开展工作的公司
    • 供应商 - 提供服务的公司向客户提供零件或服务
    • 制造商 - 制造零件的公司
  • 帐户 - 封装客户及其客户之间关系的对象
  • 工作 - 公司提供的工作单元
  • 任务 - 与特定工作相关的计费服务 零件
  • -客户作为作业或任务的一部分安装的物品
  • 库存物品 - 库存中的零件
  • 人员 - 人类的记录
    • 员工 - 与客户有业务往来的公司之一的员工
    • 技术人员 - 受雇于该公司的服务技术人员客户
    • 联系人 - 与客户打交道的特定公司的联系人
    • 管理员 - 网站管理员
  • 机会 - 任何给定帐户的潜在工作机会

建议的关系

(HO = hasOne,HM = hasMany,BT = ownTo) , HABTM = hasAndBelongsToMany)

  • 公司
    • HM:联系人、技术人员、员工
    • HABTM:管理员
  • 制造商从公司
  • 继承 供应商从公司
  • 继承 承包商从公司
  • 继承 客户从公司继承
    • HM:帐户
  • 工作
    • BT:帐户
    • HM:任务
    • HABTM:零件、承包商、技术员
  • 任务
    • BT:工作
    • HABTM:零件、承包商、技术员
  • 零件
    • HABTM:供应商
  • 库存项目
    • HO:部分
  • 员工继承自个人
    • BT:公司
  • 技术员继承自个人
    • BT:公司
  • 联系人继承自个人
    • BT:公司
  • 管理员继承个人
  • 机会
    • BT:帐户

我已尽力在 UML 图上说明这一点,尽管我不确定我的符号约定是否正确: http://twitpic.com/2o5r0a

我的问题和疑虑

  1. 如果任何,你会采用这个模式吗?为什么?
  2. 在 CakePHP 中处理对象继承的最佳方法是什么?
  3. 引导客户了解此架构并解释其如何满足项目要求的最佳方法是什么?
  4. 这个提议的设计是否会带来任何潜在的可扩展性问题?
  5. 您认为这种设计在开发应用程序代码时会带来任何困难吗?
  6. CakePHP 专家对此有什么智慧之言吗?

I'm developing an application using the CakePHP framework and am currently in the process of designing the database. I want to make sure that I design the objects and their associations correctly so that the application performs well, is organized properly, is extensible, and scales well. I will first describe the application in detail, as well as propose an Object Relationship model. I need some guidance in terms of best practice and CakePHP convention. Please read through the description, then address my questions below.

Please leave a comment if you need anything clarified.

Application Background and Requirements

The application will function as a specialized CRM of sorts. The client will be using it to track and manage customers, contacts, jobs, inventory, vendors, and opportunities. The client currently has a large database that is unorganized and application code that is broken. They need to have the database rebuilt from scratch using the CakePHP ORM and a new application built on top of the data structure. The database will be built in MySQL. The application will need to support multiple user types with access control lists. It needs to be designed to scale efficiently, and new applications will need to be built on top of the object model at a later date.

Proposed Objects (sub-bullets inherit from object above)

  • Company - any company the client does business with
    • Customer - a customer of the client
    • Contractor - a firm contracted by the client to do work
    • Vendor - a company that supplies parts or services to the client
    • Manufacturer - a company that manufactures parts
  • Account - An object that encapsulates the relationship between the client and its customers
  • Job - A unit of work provided by the company
  • Task - A billable service associated with a specific job
  • Part - An item installed by the client as part of a job or task
  • InventoryItem - A part that is in inventory
  • Person - A record of a human being
    • Employee - An employee of one of the companies the client deals with
    • Technician - A service technician employed by the client
    • Contact - A contact person for a particular company the client deals with
    • Administrator - A website administrator
  • Opportunity - A potential job opportunity for any given account

Proposed Relations

(HO = hasOne, HM = hasMany, BT = belongsTo, HABTM = hasAndBelongsToMany)

  • Company
    • HM: Contact, Technician, Employee
    • HABTM: Administrator
  • Manufacturer Inherits from Company
  • Vendor Inherits from Company
  • Contractor Inherits from Company
  • Customer Inherits from Company
    • HM: Account
  • Job
    • BT: Account
    • HM: Task
    • HABTM: Part, Contractor, Technician
  • Task
    • BT: Job
    • HABTM: Part, Contractor, Technician
  • Part
    • HABTM: Vendor
  • InventortyItem
    • HO: Part
  • Employee Inherits from Person
    • BT: Company
  • Technician Inherits from Person
    • BT: Company
  • Contact Inherits from Person
    • BT: Company
  • Administrator Inherits from Person
  • Opportunity
    • BT: Account

I've done my best to illustrate this on a UML diagram, although I'm not sure if I've gotten the notation conventions correct:
http://twitpic.com/2o5r0a

My Questions and Concerns

  1. What changes, if any, would you make to this schema and why?
  2. What is the best way to handle object inheritance in CakePHP?
  3. What is the best way to walk the client through this schema, explaining how it meets the project requirements?
  4. Does this proposed design pose any potential scalability issues?
  5. Do you forsee this design causing any difficulties when developing the application code?
  6. Any words of wisdom from CakePHP vets on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

初见 2024-09-26 17:51:18

我想帮助你,但我不想为你做你的工作。

Database Answers 上有多个 CRM 数据库图表修正。

选择一些,并将它们与您的设计进行比较。您将了解自己可能做对的事情和做错的事情。

I want to help you out, but I don't want to do your work for you.

There are several CRM databases diagrammend over at Database Answers.

Pick a few, and compare them to your design. You'll get a handle on what you might be doing right and what you might be doing wrong.

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