有哪些方法可以在数据库中存储有关匿名/来宾用户的信息?

时间:2021-08-19 12:33:39

Our application has an online shop among other features, and users are normally requested to register before completing a sale, creating a unique customer_ID in the process. When they return, they can log in and their contact details and transaction history are retrieved from the database.

我们的应用程序具有在线商店和其他功能,并且通常要求用户在完成销售之前注册,在此过程中创建唯一的customer_ID。当他们返回时,他们可以登录并从数据库中检索他们的联系详细信息和交易历史记录。

We are now exploring what to do in the case of an 'anonymous' or 'guest' customer, opening up the online shop to customers who don't want to register, and also for sales logged in the backend application, where taking the customer's email, postal address, etc is just too time consuming. The solution has applications outside the online shop too.

我们现在正在探索在“匿名”或“客户”客户的情况下该做什么,向不想注册的客户开放在线商店,以及在后端应用程序中记录的销售情况,其中服务客户的电子邮件,邮政地址等太耗时了。该解决方案也可以在网上商店之外使用。

Multiple companies use the same database, and the database is built on a party model structure, so we have explored a few options:

多个公司使用相同的数据库,数据库建立在派对模型结构上,因此我们探索了几个选项:

  1. Store all anonymous customers under one pre-defined customer_ID in the transaction table:
    1. customer_ID = 0 for every anonymous user, and customer_ID > 0 for every real user
      • This is straight-forward to hard-code into the application
      • 这是直接硬编码到应用程序中
      • But more involved to determine which customers belong to which company
      • 但更多参与确定哪些客户属于哪家公司
      • Should details for customer_ID = 0 exist in the customer table in the database or as an object in the application?
        • If in the database, what database-level constraints can be made to ensure that it always exists?
        • 如果在数据库中,可以进行哪些数据库级约束以确保它始终存在?
        • If not in the database, then foreign key constraints from transaction.customer_ID to customer.customer_ID no longer work
        • 如果不在数据库中,则从transaction.customer_ID到customer.customer_ID的外键约束不再起作用
      • customer_ID = 0的详细信息是否存在于数据库的customer表中或作为应用程序中的对象?如果在数据库中,可以进行哪些数据库级约束以确保它始终存在?如果不在数据库中,则从transaction.customer_ID到customer.customer_ID的外键约束不再起作用
    2. 每个匿名用户的customer_ID = 0,每个真实用户的customer_ID> 0这是直接硬编码到应用程序中但更多涉及确定哪个客户属于哪个公司customer_ID = 0的详细信息存在于customer表中在数据库中还是作为应用程序中的对象?如果在数据库中,可以进行哪些数据库级约束以确保它始终存在?如果不在数据库中,则从transaction.customer_ID到customer.customer_ID的外键约束不再起作用
    3. customer_ID is the same as the company party_ID
      • Easier to determine aggregate sales for each company, etc
      • 更容易确定每家公司的总销售额等
      • This would confuse matters as it would appear that the company is its own customer, rather than other unique customers
      • 这会使事情变得混乱,因为公司似乎是自己的客户,而不是其他独特的客户
    4. customer_ID与公司party_ID相同更容易确定每家公司的总销售额等。这会使事情变得混乱,因为看起来公司是自己的客户,而不是其他独特的客户
  2. 将所有匿名客户存储在事务表中的一个预定义customer_ID下:customer_ID = 0表示每个匿名用户,customer_ID> 0表示每个真实用户这是直接硬编码到应用程序中但更多涉及确定哪些客户属于哪个公司customer_ID = 0的详细信息是存在于数据库的customer表中还是作为应用程序中的对象?如果在数据库中,可以进行哪些数据库级约束以确保它始终存在?如果不在数据库中,则从transaction.customer_ID到customer.customer_ID的外键约束不再起作用customer_ID与公司party_ID相同更容易确定每个公司的总销售额等。这会使事情变得混乱,因为它看起来像公司是自己的客户,而不是其他独特的客户
  3. Generate a unique customer_ID for every new anonymous customer (per session)
    • What if the same physical user returns? There will be many records repeating the same sort of data; email, shipping address, etc.
    • 如果相同的物理用户返回怎么办?将有许多记录重复相同类型的数据;电子邮件,送货地址等
  4. 为每个新的匿名客户生成唯一的customer_ID(每个会话)如果同一个物理用户返回怎么办?将有许多记录重复相同类型的数据;电子邮件,送货地址等
  5. Use another unique key, such as email address, to refer to a customer
    • Not always reliable as people sometimes use more than one email address, or leave old addresses behind.
    • 由于人们有时会使用多个电子邮件地址或留下旧地址,因此并不总是可靠的。
    • What if there is no email address to be taken, as is the case on the shop floor, pro forma invoices, etc?
    • 如果没有电子邮件地址,如车间,备考发票等情况怎么办?
  6. 使用其他唯一密钥(例如电子邮件地址)来引用客户并不总是可靠,因为人们有时会使用多个电子邮件地址,或留下旧地址。如果没有电子邮件地址,如车间,备考发票等情况怎么办?
  7. Some other Stack Overflow inspired solution!
  8. 其他一些Stack Overflow灵感解决方案!

Addition

加成

A combination of #2 and #3 has been suggested elsewhere - attempt to store a single record for each customer, using the email address if possible, or a new record on every visit if not.

在其他地方建议使用#2和#3的组合 - 尝试为每个客户存储单个记录,如果可能,使用电子邮件地址,或者如果没有,则在每次访问时记录新记录。

I should point out that we don't need to store a record for every anonymous customer, but it just seems that the relational database was built to deal with relationships, so having a NULL or a customer_ID in the transaction table that doesn't reference an actual customer record just seems wrong...

我应该指出,我们不需要为每个匿名客户存储记录,但似乎关系数据库是为了处理关系而构建的,因此在事务表中没有引用NULL或customer_ID实际的客户记录似乎错了......

I must also stress that the purpose of this question is to determine what real-world solutions there are to recording 'casual' transactions where no postal address or email address are given (imagine a supermarket chekout) alongside online shop transactions where an email address and postal address are given whether they are stored or not.

我还必须强调,这个问题的目的是确定在没有邮政地址或电子邮件地址的情况下记录“临时”交易的真实解决方案(想象一个超市的chekout)以及电子邮件地址和网上商店交易。邮政地址是否存储。

What solutions have the SO community used in the past?

SO社区过去使用了哪些解决方案?

8 个解决方案

#1


2  

Assuming you require an e-mail address for all online orders, you could create a temporary account for every customer at the completion of each order when they are not logged in.

假设您需要所有在线订单的电子邮件地址,您可以在每个订单未完成登录时为每个客户创建一个临时帐户。

This can be done by using the shipping address and other information provided during checkout to fill in the account, and e-mailing a random temporary password to them (optionally flagging it to require changing on the first log-in, if that functionality is built into the website). This requires minimal effort on their part to setup the account, and allows them to sign in to check their order status.

这可以通过使用结账时提供的送货地址和其他信息来填写帐户,并通过电子邮件发送随机临时密码(可选地将其标记为需要更改首次登录,如果该功能已构建)进入网站)。这需要他们尽最大努力来设置帐户,并允许他们登录以检查他们的订单状态。

Since the primary key in your database is the customer_id, it should not cause conflicts if they continue making new accounts with the same e-mail/address/etc, unless you have code in place to prevent duplicates already. It's rare for someone to create more than one temporary account though, since it's easier to log in with the password e-mailed to them than entering their data again.

由于数据库中的主键是customer_id,因此如果他们继续使用相同的电子邮件/地址/等创建新帐户,则不应导致冲突,除非您已准备好代码以防止重复。虽然有人创建多个临时帐户很少见,因为使用通过电子邮件发送给他们的密码更容易登录,而不是再次输入他们的数据。

For the backend orders, we generally create an account in the same way as above for every customer. However, if they don't have an e-mail address (or they only want to purchase by phone), we generate an account with their shipping information and a blank e-mail address (have to code an exception to not send temporary passwords/order confirmations when it's blank). The customer_id is given to them, and their shipping information and company name are stored in the account to look up and expedite future orders.

对于后端订单,我们通常以与上述相同的方式为每个客户创建一个帐户。但是,如果他们没有电子邮件地址(或者他们只想通过电话购买),我们会生成一个帐户,上面有他们的送货信息和一个空白的电子邮件地址(必须编码例外,不发送临时密码/当它是空白时订购确认)。 customer_id被提供给他们,他们的运输信息和公司名称存储在帐户中以查找和加快将来的订单。

#2


1  

I doubt there are any perfect solutions to this problem. You simply have to make a choice: How important is it to guarantee recognizable customer history in contrast to the improvement in conversions you get from not forcing a customer to go through a full registration process.

我怀疑这个问题有什么完美的解决方案。您只需做出选择:与不强迫客户完成整个注册流程所获得的转化率相比,保证可识别的客户历史记录有多重要。

If you go without forcing registration, you will not be able to recognize returning customers 100% of the time. One might argue that even with registration that will not be possible, as users sometimes choose to create new accounts for various reasons. But you might be able to do something that's "good enough" by understanding the data you already have.

如果您没有强制注册,您将无法100%识别回头客。有人可能会争辩说,即使注册是不可能的,因为用户有时会出于各种原因选择创建新帐户。但是,通过了解您已有的数据,您可以做一些“足够好”的事情。

For example, in some countries, postcodes are quite specific. Are they specific enough? Depends in which countries you operate and also how your customer base is built. If you tend to only have one user per household, maybe.

例如,在某些国家/地区,邮政编码非常具体。它们足够具体吗?取决于您经营的国家以及您的客户群的构建方式。如果你倾向于每个家庭只有一个用户,也许。

Or depending on which payment methods you support, you might consider building a one-way hash of the credit card number ("pseudo-unique ID"). Some payment solutions actually do return a unique "payer ID", which could be perfect -- assuming that you get something from all the payment services you support.

或者,根据您支持的付款方式,您可以考虑构建信用卡号的单向散列(“伪唯一ID”)。一些支付解决方案确实会返回一个独特的“付款人ID”,这可能是完美的 - 假设您从所支持的所有支付服务中获得了一些东西。

#3


1  

I would assign a unique Customer ID to save the data, and then on future purchases that the same anonymous purchaser makes you could look to see if the same email address and/or first line of the address and post code already exists. If you ask for a phone number, compare that. Basically you need something fairly unique whilst getting rid of possible errors (eg. only looking at first line of the address - it's very likely that there is more than one 123 Main Street! But there will be only one 123 Main Street with post code ABC123).

我会分配一个唯一的客户ID来保存数据,然后在将来购买时,同一个匿名购买者可以查看是否已存在相同的电子邮件地址和/或地址和邮政编码的第一行。如果您要求提供电话号码,请进行比较。基本上你需要一些相当独特的东西,同时摆脱可能的错误(例如,只看地址的第一行 - 很可能有一个以上的123大街!但是只有一条123大街有邮政编码ABC123 )。

Once you know this, you could automatically create them an account - sending the customer an email saying that you've noticed that they purchased previously, and to save them time use this email address and this automatically generated password. When they login for the first time, do a quick security check (maybe value of last invoice), then let them check their details. You could even do this during the checkout process. I think by showing that you can save them time by doing it automatically could be a bonus.

一旦你知道了这一点,你就可以自动创建一个帐户 - 向客户发送一封电子邮件,说明你已经注意到他们之前购买过,并节省时间使用这个电子邮件地址和这个自动生成的密码。当他们第一次登录时,请进行快速安全检查(可能是最后一张发票的价值),然后让他们检查他们的详细信息。您甚至可以在结账过程中执行此操作。我认为通过表明你可以节省时间,自动完成它可能是一个奖励。

If you don't want to do this, then it's possible to set a cookie, though you'd have to warn the user if you are trading from within the EU (cookie laws).

如果您不想这样做,那么可以设置一个cookie,但如果您在欧盟境内进行交易(cookie法则),则必须警告用户。

The problem with someone having different email address and postal address, could be that they order for business, then they could order for personal use (hard to say as we don't know what you're selling).

有人拥有不同的电子邮件地址和邮政地址的问题可能是他们订购的商业,然后他们可以订购个人使用(很难说,因为我们不知道你在卖什么)。

#4


1  

Ofcourse you can track the sale session by using cookies. but Also register anonymous users to your site but don't let them realize that they are filling any registration form .Let them follow the sale process and at the end of the sale process generate a unique customer id and email them and also display that notification on the site after they complete their sale and make them login into the site by just entering their customer id.

当然,您可以使用cookie跟踪销售会话。但也要注册匿名用户到您的网站,但不要让他们意识到他们正在填写任何注册表。让他们按照销售过程,在销售过程结束时生成一个唯一的客户ID并通过电子邮件发送,并显示该通知在他们完成销售后在网站上,只需输入他们的客户ID即可登录网站。

#5


0  

I usually use the user IP, I create an account with just an ID and his IP address. When he registers, I just update his record. Other things than IP could (and should) be used too, like creating a random token to put in a cookie to bypass any session system in use so you can make it last longer for example.

我通常使用用户IP,我创建一个只有ID和他的IP地址的帐户。当他注册时,我只是更新他的记录。可以(也应该)使用除IP以外的其他东西,比如创建一个随机令牌放入cookie以绕过正在使用的任何会话系统,这样你可以让它持续更长时间。

Now, in the application, you have to make your user class able to "identify" your users with either this IP/token, a real session or any other login system you may have in place.

现在,在应用程序中,您必须使您的用户类能够使用此IP /令牌,真实会话或您可能具有的任何其他登录系统来“识别”您的用户。

#6


0  

The way I do it is : Not at all.

我这样做的方式是:完全没有。

Simply put, let people pay through paypal or whatever you put as payment solution and get the data from there, automatically create the user and the order after the payment is processed using the provided API.

简单地说,让人们通过paypal或任何你付款的方式付款并从那里获取数据,在使用提供的API处理付款后自动创建用户和订单。

At that point you have all the information you need and can definitely store just enough for your statistics / e-spam marketing.

此时,您拥有所需的所有信息,并且可以存储足够的信息用于统计/电子垃圾邮件营销。

Keep it simple, require NOTHING, not even people to enter a customer id or an e-mail, and they'll all love it.

保持简单,不需要任何东西,甚至人们都不能输入客户ID或电子邮件,他们都会喜欢它。

Doing that I still have every bit of information I could be interested in and the user experience is as fast/easy as can be.

这样做我仍然拥有我可能感兴趣的所有信息,并且用户体验尽可能快速/轻松。

#7


0  

Mmmm ... we generate a uniq ID for guest users -- a hash-value or uuid for the username and store this one in the basket table. You cold store this also in the customer table, if you don't mind cluttering your database with such data. The uuid is stored in a cookie in the customers browser, until he checks out the basket. The cookie thing is also nice for assigning the anonymous account (and the content of it's basket) to a valid account, if the user decided to register later on / before checking out the basket.

嗯...我们为访客用户生成一个uniq ID - 用户名的哈希值或uuid,并将这个存储在篮子表中。如果您不介意使用此类数据使数据库混乱,您也可以在customer表中进行冷存储。 uuid存储在客户浏览器的cookie中,直到他签出篮子。如果用户决定稍后/在签出购物篮之前注册,那么cookie的内容也很适合将匿名帐户(及其篮子的内容)分配给有效帐户。

#8


0  

I would create a unique customer ID, and store it on the user's machine as a cookie. This should decrease the number of users with multiple customer IDs.

我会创建一个唯一的客户ID,并将其作为cookie存储在用户的计算机上。这应该会减少具有多个客户ID的用户数量。

But in all seriousness, as long as your number of ids isn't getting into the hundreds of thousands (and congrats if it is!), it's not going to hurt your database as long as you have proper indexes on the customer id column.

但严肃地说,只要你的id数量没有达到数十万(并且恭喜,如果它!),只要你在客户id列上有适当的索引,就不会损害你的数据库。

If you had id=0 for each customer wouldn't you have just as many rows though? I think that's inescapable if you want to keep all the data, right? A zero id might cause your index extra problems too.

如果你的每个客户都有id = 0,你会不会有尽可能多的行?如果你想保留所有数据,我认为这是不可避免的,对吗?零id可能会导致索引出现额外问题。

#1


2  

Assuming you require an e-mail address for all online orders, you could create a temporary account for every customer at the completion of each order when they are not logged in.

假设您需要所有在线订单的电子邮件地址,您可以在每个订单未完成登录时为每个客户创建一个临时帐户。

This can be done by using the shipping address and other information provided during checkout to fill in the account, and e-mailing a random temporary password to them (optionally flagging it to require changing on the first log-in, if that functionality is built into the website). This requires minimal effort on their part to setup the account, and allows them to sign in to check their order status.

这可以通过使用结账时提供的送货地址和其他信息来填写帐户,并通过电子邮件发送随机临时密码(可选地将其标记为需要更改首次登录,如果该功能已构建)进入网站)。这需要他们尽最大努力来设置帐户,并允许他们登录以检查他们的订单状态。

Since the primary key in your database is the customer_id, it should not cause conflicts if they continue making new accounts with the same e-mail/address/etc, unless you have code in place to prevent duplicates already. It's rare for someone to create more than one temporary account though, since it's easier to log in with the password e-mailed to them than entering their data again.

由于数据库中的主键是customer_id,因此如果他们继续使用相同的电子邮件/地址/等创建新帐户,则不应导致冲突,除非您已准备好代码以防止重复。虽然有人创建多个临时帐户很少见,因为使用通过电子邮件发送给他们的密码更容易登录,而不是再次输入他们的数据。

For the backend orders, we generally create an account in the same way as above for every customer. However, if they don't have an e-mail address (or they only want to purchase by phone), we generate an account with their shipping information and a blank e-mail address (have to code an exception to not send temporary passwords/order confirmations when it's blank). The customer_id is given to them, and their shipping information and company name are stored in the account to look up and expedite future orders.

对于后端订单,我们通常以与上述相同的方式为每个客户创建一个帐户。但是,如果他们没有电子邮件地址(或者他们只想通过电话购买),我们会生成一个帐户,上面有他们的送货信息和一个空白的电子邮件地址(必须编码例外,不发送临时密码/当它是空白时订购确认)。 customer_id被提供给他们,他们的运输信息和公司名称存储在帐户中以查找和加快将来的订单。

#2


1  

I doubt there are any perfect solutions to this problem. You simply have to make a choice: How important is it to guarantee recognizable customer history in contrast to the improvement in conversions you get from not forcing a customer to go through a full registration process.

我怀疑这个问题有什么完美的解决方案。您只需做出选择:与不强迫客户完成整个注册流程所获得的转化率相比,保证可识别的客户历史记录有多重要。

If you go without forcing registration, you will not be able to recognize returning customers 100% of the time. One might argue that even with registration that will not be possible, as users sometimes choose to create new accounts for various reasons. But you might be able to do something that's "good enough" by understanding the data you already have.

如果您没有强制注册,您将无法100%识别回头客。有人可能会争辩说,即使注册是不可能的,因为用户有时会出于各种原因选择创建新帐户。但是,通过了解您已有的数据,您可以做一些“足够好”的事情。

For example, in some countries, postcodes are quite specific. Are they specific enough? Depends in which countries you operate and also how your customer base is built. If you tend to only have one user per household, maybe.

例如,在某些国家/地区,邮政编码非常具体。它们足够具体吗?取决于您经营的国家以及您的客户群的构建方式。如果你倾向于每个家庭只有一个用户,也许。

Or depending on which payment methods you support, you might consider building a one-way hash of the credit card number ("pseudo-unique ID"). Some payment solutions actually do return a unique "payer ID", which could be perfect -- assuming that you get something from all the payment services you support.

或者,根据您支持的付款方式,您可以考虑构建信用卡号的单向散列(“伪唯一ID”)。一些支付解决方案确实会返回一个独特的“付款人ID”,这可能是完美的 - 假设您从所支持的所有支付服务中获得了一些东西。

#3


1  

I would assign a unique Customer ID to save the data, and then on future purchases that the same anonymous purchaser makes you could look to see if the same email address and/or first line of the address and post code already exists. If you ask for a phone number, compare that. Basically you need something fairly unique whilst getting rid of possible errors (eg. only looking at first line of the address - it's very likely that there is more than one 123 Main Street! But there will be only one 123 Main Street with post code ABC123).

我会分配一个唯一的客户ID来保存数据,然后在将来购买时,同一个匿名购买者可以查看是否已存在相同的电子邮件地址和/或地址和邮政编码的第一行。如果您要求提供电话号码,请进行比较。基本上你需要一些相当独特的东西,同时摆脱可能的错误(例如,只看地址的第一行 - 很可能有一个以上的123大街!但是只有一条123大街有邮政编码ABC123 )。

Once you know this, you could automatically create them an account - sending the customer an email saying that you've noticed that they purchased previously, and to save them time use this email address and this automatically generated password. When they login for the first time, do a quick security check (maybe value of last invoice), then let them check their details. You could even do this during the checkout process. I think by showing that you can save them time by doing it automatically could be a bonus.

一旦你知道了这一点,你就可以自动创建一个帐户 - 向客户发送一封电子邮件,说明你已经注意到他们之前购买过,并节省时间使用这个电子邮件地址和这个自动生成的密码。当他们第一次登录时,请进行快速安全检查(可能是最后一张发票的价值),然后让他们检查他们的详细信息。您甚至可以在结账过程中执行此操作。我认为通过表明你可以节省时间,自动完成它可能是一个奖励。

If you don't want to do this, then it's possible to set a cookie, though you'd have to warn the user if you are trading from within the EU (cookie laws).

如果您不想这样做,那么可以设置一个cookie,但如果您在欧盟境内进行交易(cookie法则),则必须警告用户。

The problem with someone having different email address and postal address, could be that they order for business, then they could order for personal use (hard to say as we don't know what you're selling).

有人拥有不同的电子邮件地址和邮政地址的问题可能是他们订购的商业,然后他们可以订购个人使用(很难说,因为我们不知道你在卖什么)。

#4


1  

Ofcourse you can track the sale session by using cookies. but Also register anonymous users to your site but don't let them realize that they are filling any registration form .Let them follow the sale process and at the end of the sale process generate a unique customer id and email them and also display that notification on the site after they complete their sale and make them login into the site by just entering their customer id.

当然,您可以使用cookie跟踪销售会话。但也要注册匿名用户到您的网站,但不要让他们意识到他们正在填写任何注册表。让他们按照销售过程,在销售过程结束时生成一个唯一的客户ID并通过电子邮件发送,并显示该通知在他们完成销售后在网站上,只需输入他们的客户ID即可登录网站。

#5


0  

I usually use the user IP, I create an account with just an ID and his IP address. When he registers, I just update his record. Other things than IP could (and should) be used too, like creating a random token to put in a cookie to bypass any session system in use so you can make it last longer for example.

我通常使用用户IP,我创建一个只有ID和他的IP地址的帐户。当他注册时,我只是更新他的记录。可以(也应该)使用除IP以外的其他东西,比如创建一个随机令牌放入cookie以绕过正在使用的任何会话系统,这样你可以让它持续更长时间。

Now, in the application, you have to make your user class able to "identify" your users with either this IP/token, a real session or any other login system you may have in place.

现在,在应用程序中,您必须使您的用户类能够使用此IP /令牌,真实会话或您可能具有的任何其他登录系统来“识别”您的用户。

#6


0  

The way I do it is : Not at all.

我这样做的方式是:完全没有。

Simply put, let people pay through paypal or whatever you put as payment solution and get the data from there, automatically create the user and the order after the payment is processed using the provided API.

简单地说,让人们通过paypal或任何你付款的方式付款并从那里获取数据,在使用提供的API处理付款后自动创建用户和订单。

At that point you have all the information you need and can definitely store just enough for your statistics / e-spam marketing.

此时,您拥有所需的所有信息,并且可以存储足够的信息用于统计/电子垃圾邮件营销。

Keep it simple, require NOTHING, not even people to enter a customer id or an e-mail, and they'll all love it.

保持简单,不需要任何东西,甚至人们都不能输入客户ID或电子邮件,他们都会喜欢它。

Doing that I still have every bit of information I could be interested in and the user experience is as fast/easy as can be.

这样做我仍然拥有我可能感兴趣的所有信息,并且用户体验尽可能快速/轻松。

#7


0  

Mmmm ... we generate a uniq ID for guest users -- a hash-value or uuid for the username and store this one in the basket table. You cold store this also in the customer table, if you don't mind cluttering your database with such data. The uuid is stored in a cookie in the customers browser, until he checks out the basket. The cookie thing is also nice for assigning the anonymous account (and the content of it's basket) to a valid account, if the user decided to register later on / before checking out the basket.

嗯...我们为访客用户生成一个uniq ID - 用户名的哈希值或uuid,并将这个存储在篮子表中。如果您不介意使用此类数据使数据库混乱,您也可以在customer表中进行冷存储。 uuid存储在客户浏览器的cookie中,直到他签出篮子。如果用户决定稍后/在签出购物篮之前注册,那么cookie的内容也很适合将匿名帐户(及其篮子的内容)分配给有效帐户。

#8


0  

I would create a unique customer ID, and store it on the user's machine as a cookie. This should decrease the number of users with multiple customer IDs.

我会创建一个唯一的客户ID,并将其作为cookie存储在用户的计算机上。这应该会减少具有多个客户ID的用户数量。

But in all seriousness, as long as your number of ids isn't getting into the hundreds of thousands (and congrats if it is!), it's not going to hurt your database as long as you have proper indexes on the customer id column.

但严肃地说,只要你的id数量没有达到数十万(并且恭喜,如果它!),只要你在客户id列上有适当的索引,就不会损害你的数据库。

If you had id=0 for each customer wouldn't you have just as many rows though? I think that's inescapable if you want to keep all the data, right? A zero id might cause your index extra problems too.

如果你的每个客户都有id = 0,你会不会有尽可能多的行?如果你想保留所有数据,我认为这是不可避免的,对吗?零id可能会导致索引出现额外问题。