1

我有 2 个表:成员表和邮件列表表。

[Members] 
Username
Password
EmailAddress
MailingListOptIn [bit]
Planes [bit]
Boats [bit]
Cars [bit]
  • 水果列是用户偏好。

[MailingList]
EmailAddress
MailingListOptIn
  • mailinglist'er 可以选择接收时事通讯,但不一定是会员

我想开始存储邮件列表的首选项。我的问题是合并这两个表数据的最佳方法是什么?

我已经尝试使用仅存储用户名、密码等成员信息的成员表和存储电子邮件地址和首选项的单独配置文件表。成员和邮件列表首选项都可以存储在此配置文件表中,但我无法添加 FK 约束,因为我无法添加邮件列表。

所以现在我的选择是:

  1. 坚持使用 2 个表,但在邮件列表表上引入重复的“首选项”列。
  2. 使用单一配置文件表和螺钉参照完整性。

或者也许还有另一种更好的方法?

4

2 回答 2

1
CREATE TABLE Profiles (
 Username
 Password
 EmailAddress
 MailingListOptIn [bit]
 Planes [bit]
 Boats [bit]
 Cars [bit]
);

CREATE VIEW Members AS
  SELECT * FROM Profiles WHERE Username IS NOT NULL
  WITH CHECK OPTION;

CREATE VIEW MailingList AS 
  SELECT EmailAddress, MailingListOptIn, Planes, Boats, Cars
  FROM Profiles WHERE Username IS NULL
  WITH CHECK OPTION;
于 2009-06-03T17:20:21.763 回答
0

I would do it like this:

i) a "person" table with the email address as key

ii) a "member" table, only members will have a record in this table, linked to "person" by emailaddress (also key in this table)

iii) a "mailingList" table, having a unique id for the mailingList, the description and maybe other fields

iv) a "mailingListSubscriber" table (a relationship) with the email address of the person and the id of the mailing list.

Sorry for adding tables but I think it's the minimal setting for adequate normalization given the requirements.

于 2009-06-03T16:21:11.550 回答