最好的数据库设计方法加入复杂的数据ASP.Net成员表 [英] Best database design approach to join complex data to ASP.Net Membership tables

查看:123
本文介绍了最好的数据库设计方法加入复杂的数据ASP.Net成员表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个稍微修改的ASP.Net成员资格提供程序来处理标准用户帐户创建/认证/等的网站。我们有遗留数据相当数量的,我需要,以提供连续性与我们现有的用户保存的信息(如订单历史记录,心愿等)迁移。 [注:我们反正迁移,所以这不是我们要迁移数据的原因]

I'm looking to use a slightly modified ASP.Net Membership Provider to handle the standard user account creation/authentication/etc in a website. We have a fair amount of legacy data that I need to migrate in order to provide continuity with our existing users' saved information (like order history, wishlist, etc). [NOTE: We have to migrate anyway, so this is not the reason we're migrating data]

我不知道一个明智的做法是什么加入这一额外的数据到asp.net成员资格表。这里有两个独特的钥匙,我可以在用户表上使用 - 用户ID或电子邮件 - 我们将作为用户名的替代使用

I'm wondering what a sensible approach is for joining this additional data to the asp.net membership tables. There are a two unique keys that I could use on the user table - UserId or email - which we will use as a surrogate for username.

我的问题是,什么是更好的访问模式(因此外键)在我的表的其他地方使用,用于存储订单,心愿等?

My question is, what is the better access pattern (and hence foreign key) to use elsewhere in my tables for storing orders, wishlists, etc?

在HttpContext的,一个User对象是可用的包含的用户名,我们的电子邮件地址,
但不具备的Guid可用用户id

In HttpContext, a User object is available that contains the "Username", our email address, but doesn't have the Guid for userId available.

我看到3个选项:


  1. 我想简单地使用用户ID UNIQUEIDENTIFIER超过一个漫长的varchar电子邮件地址的访问效率,而且无需额外的数据库调用通过电子邮件/登录来获取它,它不会出现一应俱全。是否有某种方式来获得用户ID,所以我可以使它在不同的表的外键?

  2. 我可以在电子邮件地址(用户名)作为输入参数传递,加入的用户id,其中电子邮件地址= @emailAddress,并使用用户ID作为对其他表的外键。

不可行


  1. 我可以在所有其他表的外键存储的用户名/电子邮件地址 - 这将是一个不幸的非规范化

无论是从DB角度,还是从应用的角度效率上最好的方法有什么想法?

Any thoughts on a best method from either a DB perspective or from an application efficiency perspective?

推荐答案

您可以获取用户名:

MembershipUser myObject = Membership.GetUser();
        string UserID = myObject.ProviderUserKey.ToString();

或者(请检查)

  string userId = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();

这篇关于最好的数据库设计方法加入复杂的数据ASP.Net成员表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆