0

我目前正在着手学习 PHP 和 MySQL 的新事业。过去我使用 Access 做过一些简单的数据库,但这个数据库是一个以 Web 为中心的数据库,用于跟踪包括联系人和项目信息在内的无数数据。我需要以各种关系链接各种表,我不确定最好的方法。由于我刚刚开始使用 PHP/MySQL,因此我正在研究在线资源以尽可能多地学习。如果有人对书籍或网站有建议,我将不胜感激。

在设置我的表格时,我关心的一个主要领域是联系人。我将拥有各种联系人,包括:员工、客户、供应商、分包商等。单个联系人可以是多种类型,每种类型都有与其相关的各种附加字段。我的想法是有一个联系人表,该表可以链接到各种联系人类型的其他表。我不确定哪种字段类型或表格选项的设置最好...想法?

这种情况可能会在数据库的其他领域以及项目和产品中出现。

任何指针/方向将不胜感激。

WES

4

3 回答 3

0

I would give a little thought to how you're going to use those extended fields. Certainly create a table for contacts, and you definitely could create a table for each contact type (employees, clients, etc) with a column connecting the record to the contact table (thus employees would have employee_id, contact_id, propertyOne, propertyTwo, etc).

Another option though, which may be convenient if your application is contact centric and you really just want to be able to associate different kinds of information with contacts, would be to have a contact table, a table containing the types of extended information (say "contactTypes" and it would have the information that a vendor type has a billing address for example) and a third table to actually hold all the data (name-value pairs). This is a bit more fluid in that it will let you add new types of contacts or add fields to a type without actually altering your schema. The first option (Jason McCreary's) might scale better if you're going to have many, many records...

Regarding resources - there's so much out there, I can't even begin to narrow it down for you - look at the php manual and just google "php mysql tutorial" - tons of stuff.

于 2012-06-05T16:56:03.017 回答
0

你熟悉面向对象设计吗?

在 RDBMS 中,例如 MySQL,我会按如下方式设计数据库:

  • 联系人(名字、姓氏等)
    • 雇员
    • 供应商
    • 客户
    • ETC

扩展 的表Contacts将保存其特定数据以及contact_id创建关系的列。

顺便说一句,NoSQL解决方案本身就解决了这个问题,因为它们没有严格的模式。这意味着您可以为每条记录保存各种数据。

于 2012-06-05T16:38:29.480 回答
0

我推荐的一本对我有很大帮助的书是Beginning-PHP-MySQL-Novice-Professional

并确保您观看以下视频,但如果您不了解基础知识,它可能会更高级。Bbuild-a-login-system-for-a-simple-website/

对于数据库关系以及介绍,请访问Coding HORROR

我希望这有帮助..

于 2012-06-05T17:00:51.833 回答