数据库结构.. Ugg ?

发布于 2024-11-02 05:40:27 字数 638 浏览 2 评论 0原文

好吧,这可能看起来很愚蠢,但我想确保我是对的。

我有一个足够简单的数据库设置:

Table_Customer
  ID  (PK)
  Acc_number
  First
  Last
  etc.

Table_Notes
  ID (PK)
  Note_Type_FK (links to Table_Note_type)
  Note
  Account_FK (Links to Table_Customer)

Table_Note_Type
  ID (PK)
  Note_Type_Name
  Note_Type_Desc

Notes用于与该客户相关的所有注释,并且可以用于技术支持、销售跟进等。该表有一个链接到Note_Type的FK code> 和 FK 返回到 Customer 中的 Acc_number

我的问题

  1. 此设置正确吗?
  2. 使用 SQL,当我添加/更新客户并选择注释类型(例如技术支持)并输入该客户的注释时,当我运行插入语句时,我应该做什么/注意什么?

这是一个简单的问题,但我想确保我做得正确。

Ok, So this may seem silly but I want to make sure I am right.

I have a simple enough database setup:

Table_Customer
  ID  (PK)
  Acc_number
  First
  Last
  etc.

Table_Notes
  ID (PK)
  Note_Type_FK (links to Table_Note_type)
  Note
  Account_FK (Links to Table_Customer)

Table_Note_Type
  ID (PK)
  Note_Type_Name
  Note_Type_Desc

Notesis for all notes relating to that customer and can be for tech support, sales follow up, etc. This table has a FK linked to Note_Type and a FK back to Acc_number in Customer.

My Questions:

  1. Is This set up correctly?
  2. Using SQL, when I add/update a customer and select a note type (eg, Tech Support) and type in a note for that customer, is there anything I should be doing / watching out for when I run the insert statement ?

Its a simple question, but I want to make sure I am doing this correctly.

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

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

发布评论

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

评论(3

栩栩如生 2024-11-09 05:40:27

对于简单的 CRM 类软件来说,该设置似乎是正确的,但如果没有完整的系统要求,我们无法回答它是否正确。

至于插入,只要 CustomerNote_Type 都已经存在,一切都应该没问题。一开始让一些人困惑的一件事是确保级联规则按照他们想要的外键方式设置。根据要求,您可能希望在删除 Customer(级联删除)时删除所有 Notes,或者您可能希望要求所有 Notes< /code> 首先显式删除,允许删除 Customer 之前(级联限制)

The setup seems correct for a simple CRM sort of software, but without the full system requirements, we can't answer if it is correct or not.

As far as inserting, as long as both the Customer and the Note_Type already exist, everything should be fine. The one thing that trips some people up at first is making sure the cascade rules are set the way they want them on the Foreign Keys. Depending on the requirements, you might want to have all Notes deleted when you delete a Customer (cascade delete), or you might want to require that all Notes are explicitly deleted first, before the Customer is allowed to be deleted (cascade restrict)

天暗了我发光 2024-11-09 05:40:27

您的结构是正确的,但您可能需要重新考虑您的命名方案。尽管命名方案可能有很大差异,但在所有数据库表中添加 tblTable_ 前缀通常不被认为是好的做法。 Narayana Vyas Kondreddi 撰写的这篇文章似乎是关于 SQL Server 命名约定最广泛接受的指南之一:

http ://vyaskn.tripod.com/object_naming.htm

SQL命名约定的问题之前也在这个网站上得到过解答,参见:

Microsoft 的数据库命名约定?

Your structure is correct, but you may want to rethink your naming scheme. Although naming schemes can vary widely, it's generally not considered good practice to prefix all your database tables with tbl or Table_. This article authored by Narayana Vyas Kondreddi seems to be one of the most widely accepted guides on SQL Server naming conventions:

http://vyaskn.tripod.com/object_naming.htm

The question of SQL naming conventions has also been answered on this site before, see:

Database Naming Conventions by Microsoft?

一片旧的回忆 2024-11-09 05:40:27

你的方法将会奏效。有一件事值得一提;如果帐号是唯一的,则不需要客户表中的 ID。

这是一个适合您目的的简单 ERD。

在此处输入图像描述

Your approach will work. One thing to mention; you don't need ID in customer table if account number is unique.

Here's a simple ERD for your purpose.

enter image description here

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