需要 MySQL 表架构帮助

发布于 2024-10-30 08:57:56 字数 278 浏览 2 评论 0原文

我在决定将某个表字段放置在数据库中的位置时遇到问题。 该数据库用于分类广告网站。 我希望注册和非注册用户都能够发布广告。如果未注册的用户发布广告,网站应询问他的联系电话,如果用户已经注册,则应使用用户表中存储的联系电话。

现在我的问题是,是否可以将注册用户和未注册用户的联系电话存储在同一个表字段中? 如果是这样,该字段应该放在哪里,在分类广告表中,还是在用户表中(请注意,表中的每个用户都有一个唯一的 ID,因此,用未注册的用户填充用户表只是为了获取他们的联系方式电话只会在表格中填入无用的数据)

提前致谢!

I've a problem deciding where to place a certain table field within my database.
The database is for a classified ads website.
I want registered and non-registered users to be able to post ads. If an unregistered user posts an ad, the site should ask him for the contact phone, if the user is already registered, then the contact phone stored in the users' table should be used.

Now my question is, would it be possible to store the contact phone for both registered and unregistered users in the same table field?
If so, where should that field be put, in the Classified ads table, or in the users' table (noting that each user within the table has a unique Id, thus, filling the users' table with unregistered users just to get their contact phone will just fill the table with useless data)

Thanks in advance !

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

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

发布评论

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

评论(3

淡墨 2024-11-06 08:57:56

那么您可以将电话字段放入广告表中,其中包含 is_registered 字段。然后通过 php 检查 is_registered 然后你就知道在哪里搜索电话号码了。

问候

well you can put the phone field in the ads table, with a is_registered field inside. Then via php you check is_registered and then you know where to search for phone number.

Regards

初心 2024-11-06 08:57:56

您可以将未注册用户的电话号码存储在同一个表的同一列中,您可能应该这么做。它使从未注册用户到注册用户的转换变得非常简单——您无需移动或重新输入电话号码。如果任何用户更改电话号码,只需在一处更新即可。 (您知道每天有多少人不小心将手机掉进厕所吗?这太惊人了。)

如果您现在依靠电话号码来识别注册用户,则需要首先解决这个问题。 (我不认为你正在这样做,但如果你这样做,请先解决这个问题。)

你说

用以下内容填充用户表
未注册用户只是为了获得他们的
联系电话将填入表格
带有无用数据

如果无用,就不要存储它。如果你需要存储它,它也不是没有用处。

当分类广告终止时,您始终可以删除未注册的用户。但 。 。 。

要求提供联系电话号码而不是让用户选择留下电话号码或电子邮件地址是否有意义?就我个人而言,我更喜欢使用一次性电子邮件地址来处理此类事情。

You can store unregistered users' phone numbers in the same column of the same table, and you probably should. It makes the transition from unregistered user to registered user dead simple--you don't have to move or re-enter phone numbers. And if any user changes phone numbers, it only has to be updated in one place. (Do you know how many people accidentally drop their cell phones in a toilet every day? It's staggering.)

If you're now relying on the presence of a phone number to identify registered users, you'll need to fix that first. (I don't think you're doing that, but if you are, fix that first.)

You said

filling the users' table with
unregistered users just to get their
contact phone will just fill the table
with useless data

If it's useless, don't store it. If you need to store it, it's not useless.

You can always delete unregistered users when their classified ad terminates. But . . .

Does it make sense to require a contact phone number instead letting the user choose to leave either a phone number or an email address? Personally, I prefer to use a throw-away email address for things like this.

三生路 2024-11-06 08:57:56

我会在您的设计中寻求灵活性,但是如果您的逻辑主要独立于用户是否注册而对待用户,那么我将使用同一个表,并为已注册的用户完成其余的用户数据。我不会将用户数据存储在广告表中,即使只是为了数据组织的清晰性。

我想您的注册用户都会有一个用户名和密码,因此您只需检查这些用户名和密码是否存在即可知道他们是否已注册。如果您不想将来改变您的逻辑,那么您当然应该谨慎选择这种区别。

不同的方法:为什么不让注册变得如此简单,让未注册的用户变得毫无意义?如果您在所有情况下都要求提供电话号码,只需添加密码字段或自动生成一个密码字段,即可注册所有用户。

我会要求您提供电子邮件,以便您可以发送密码,并可能要求进行帐户验证(现在或将来)。

I would look for flexibility in your design, but if your logic treats users mostly independently of whether they are registered or not, I would use the same table and just complete the rest of the user's data for the registered ones. I wouldn't store user data on the ads table, even if only for clarity of data organization.

I guess your registered users will all have a username and password, so you can just check the presence of these to know if they are registered or not. If you don't want to change your logic in the future you should choose this distinction carefully of course.

A different approach: Why not making registration so easy that it makes no sense to have unregistered users? I you are already asking for a phone number in all cases, just add a password field or generate one automatically and you have all your users registered.

I would ask for an email so you can send the password and perhaps ask for account verification (now or in the future).

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