设计用户单表登录以在子域中使用 [英] Design users table for single sign in to use across sub domains
问题描述
我们有一个网站,其子域名如下:
- example.com - 主要网站
- food.example.com
- fashion.example.com
每个域和子域都有一个不同的数据库,如下所示:
- exampleDB / em>
- foodDB
- fashionDB
您尝试了什么?
-
现在,单点登录我们计划重定向用户在我们的主要网站上注册。
-
虽然子域中的订单处理从主数据库获取UserID,并存储在相应子域的订单表中。 >
-
为了报告,我们存储
UserID
而不使用FK约束
Orders
表,因为我们有单独的数据库。
我可以看到这里堆栈交换站点有单独的数据库,但是它有单独的用户表格?
StackExchange网络配置文件是否存储在单独的数据库中?
我可以从这里每个网站的用户表都有StackExchange网络配置文件的AccountId。
示例:
在中的任何地方,我看不到帐户
数据愚弄,所以是 AccountId
存储?如何使用 AccountId
在多个网站上完成SSO?
我的问题:我们在主数据库中需要一个用户表,或者我们必须为子域的数据库和 Link Main DB UserID
而不是FK约束创建单独的用户表。
任何帮助都会很棒。
您提到的UserID在单个DB中的特定Users表中只相同。它实际上不是您域中任何用户的标识符。要识别多个数据库中的用户,您需要为每个用户提供域级别的ID。一个简单的方法是添加一个名为UID的属性(列)或类似于User Class(table)的全局唯一ID(GUID,请参阅 https://msdn.microsoft.com/en-us/library/system.guid(v = vs.110)。 aspx ),并将其用作域级ID来标识用户而不是UserId。通过这种方式,您可以将用户信息自由存储在您域中的多个数据库中所以:
- 您可以在每个子域的数据库中只保留域级ID,并使用该ID从主要查询完整的用户配置文件域DB。优点:成本较低记忆力。权衡:在分布式系统中,由于信息驻留在主数据库中,从子域查询用户信息需要更长时间。
- 可以在所有数据库中保存完整的用户信息,包括主要和次要。 Pro:查询速度更快缺点:成本更高,用户信息更改时,您必须在所有数据库中进行同步。
We have a site which has sub domains like:
- example.com - Main Site
- food.example.com
- fashion.example.com
And each domain and sub domain has a different database, like this:
- exampleDB - Main DB with Users Table
- foodDB
- fashionDB
What have you tried?
Right now, for single sign in we have planned to redirect users in our Main Site for signing up.
While order processing in sub domains get the UserID from main DB and store in respective sub domain's Orders table.
For reporting purposes we store the
UserID
withoutFK constraint
in theOrders
table since we have separate database.
I can see here that stack exchange sites have separate databases, but does it have separate users tables too?
Does StackExchange Network profile is stored in a separate database?
I can see from here that Every site's user table has AccountId of StackExchange Network profile.
An Example:
Here is Nick Craver Network Profile with ID:7598
His profile in History Site has Account ID Linked with same ID:7598 check this query.
I can't see the Accounts
table anywhere in data dumbs , So Were is AccountId
stored? And how is SSO done in multiple sites using AccountId
?
My Question: Do we need a single user table in Main DB or we have to create separate user tables for the sub domain's database and Link Main DB UserID
but not FK constraint? Which is the best design for a shopping site?
Any help would be great.
The UserID you mentioned is only identical in a specific Users table in a single DB. It's actually not an identifier of any user in your domain. To identify users across multiple databases, you will need a domain-level ID for every user. A simple way is to add one more property (column) named UID or something like that to User class (table), of Global Unique Id (GUID, see https://msdn.microsoft.com/en-us/library/system.guid(v=vs.110).aspx) and use it as domain-level ID to identify users instead of UserId. This way you can freely store user information in multiple databases in your domain. So:
- You can hold only domain-level ID in every sub-domain's database and use that ID to query full user profiles from the main domain DB. Pros: costs less memory. Trade-off: in a distributed system, it takes longer to query user information from sub-domain because the information residing in main DB.
- You can hold full user information in all DB, including main's and subs'. Pro: faster queries. Cons: costs more memory and when a user information changes, you will have to synchronize it across all databases.
这篇关于设计用户单表登录以在子域中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!