System allows mobile phone and mailbox registration, how to ensure uniqueness

Source: Internet
Author: User
Keywords Php
If only mobile phone registration, as long as the mobile phone to do a unique index, but if the mailbox can also be registered, the incoming is not necessarily a mobile phone, that is, mobile and email two can not set a unique index, because if two mobile phone users registered in, there will be two e-mail records of empty, There are no unique cases, and vice versa. What's the deal?

Reply content:

If only mobile phone registration, as long as the mobile phone to do a unique index, but if the mailbox can also be registered, the incoming is not necessarily a mobile phone, that is, mobile and email two can not set a unique index, because if two mobile phone users registered in, there will be two e-mail records of empty, There are no unique cases, and vice versa. What's the deal?

I feel there are two kinds of solutions:
1. Email and mobile are set to the same field.
2, email and mobile are also set to unique, but allow null, when the same is null can be inserted in a successful

Mobile + mailbox To do a unique index?

The upper two fields are judged to be feasible at the same time.
But do you have to use these two fields as a unique index? Add another field, adding a unique index value to the record, I don't know.

You set up your phone and mailbox as a federated unique index.
UNIQUE INDEX table (' mobilephone ', ' email ')

This is easy. Select Mailbox Registration The mailbox is a unique identifier (for login) and can be tied to multiple phones. If the phone is registered, the phone is uniquely identified and can theoretically be bound to multiple mailboxes (but most of the actual prohibitions are multiple). This status can be registered by mobile phone and email two non-affected login account. So uniqueness is a must, but different types of accounts can exist what you call not unique! Get a good understanding of it!

You can use a meaningless unique number as the user's index, and then register to determine if the phone or mailbox you are using has already been registered. If you have not registered, generate a new unique number as the index for this newly registered user.

The uniqueness of the mailbox and the phone is guaranteed by the judgment at the time of registration.

However, if a user supplements a phone or mailbox that is not filled in at the time of registration, it is necessary to consider whether or not you still want to be unique.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.