开发者

Relation between Users and Dinners in Nerddinner project

In Nerddinner project, i see that dinners has relation to users by username if i didn't understand it wrongly. I expected that dinners would have relation to users by unique identifiers. There is no something wrong about it? If we want to change username of user so we should to consider manually update relations. Please consider old questions which asked why it i开发者_运维知识库s not better idea to use username as unique identifiers.


I don't have the exact database schema in mind, but as far as I know, user management is handled by ASP.NET built-in membership facilities in the membership database. While you can get unique ID from ASP.NET membership providers, the type of that identifier can vary across different providers (e.g. could be Int32 in one provider and Guid in another as providerUserKey argument in membership API is declared of type object). Therefore, if you want to isolate yourself from any specific membership provider, you'd better stick to the username. It's portable.


Username is a unique identifier in this example. You don't need to use int or uniqueidentifier (Guid) as the key if there is a more natural key. In this instance username is unique within the system so is a natural key for the user records.


You are correct; the user names are used as the unique identifier that ties users to dinners (or to the RSVPs, as I recall).

It uses those values because user names must be unique already, so it is a unique ID... it's just not a numeric, auto-generated one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜