有空信息是真的吗? [英] Is it true to have a null info?

查看:73
本文介绍了有空信息是真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想设计一个购物系统,

我的系统有一些用户 - > (admin(*) - admin(level2) - 卖方 - 买方(已注册) - 买方(未注册))。

i有两张表用于注册:



1-用户(UserID(pk) - 角色 - 用户名 - 密码)



2- UserInfo(UserInfoID(pk) - tel - name - fname - 地址 - 城市 - 用户ID(fk))



i想要设置用户名和密码可以为空,因为我想在没有任何用户名和密码的情况下注册一些买家信息(买家不是注册)。

i不允许其他用户插入null用户名和密码。

i检查他们是否输入了用户名和密码,以便他们注册。

但是用户名和密码字段是可以为空的。

是否有一些行没有任何用户名和密码是真的,但有些行有它们吗?



我尝试了什么:



除了用户名和密码fiels之外,所有字段都是强制性的,但是想要注册的用户应该插入他们(我检查他们是否没有插入这些字段无法注册)。

null仅适用于非注册用户。

hello,
i want to design a shopping system,
my system has some user -> ( admin(*) - admin(level2) - seller - buyer(registered) - buyer(not registered) ).
i have two table for register :

1- User (UserID(pk) - role - username - password)

2- UserInfo (UserInfoID(pk) - tel - name - fname - address - city - UserID(fk))

i want to set username and password nullable because i want to register some buyers info without any username and password (buyer who not registered).
i dont give permission to other user for insert null username and password.
i check if they inserted username and password therefor they can register.
but username and password fields are nullable.
is it true to have some rows without any username and password but for some rows have them?

What I have tried:

all of the fields are mandatory except username and password fiels but users who wants to register should insert them(i check if they didnt insert these field cant register).
null able is just for not register users.

推荐答案

你可以拥有可空用户名和密码(因为你的PK是ID列),因为每一行都是相互独立的,null是允许的值。



我自己不会这样做,因为没有任何真正的需求 - 相反,我可能会在您的角色列表中添加一个匿名用户并使用该角色 - 这样您也可以让系统更容易限制他们可以看到的内容如有必要,请将其转移到注册页面。我使用新客户和空白密码而不是空用户名和密码,让角色处理他们需要做的事情。

(这也减少了你必须做的工作因为您可以在购物篮的每个页面上显示用户名,而无需为空值添加额外的检查)
You can have nullable username and password (since your PK is the ID column) because each row is independant of each other and null is a permitted value.

I wouldn't do it myself, as there isn't any "real" need - instead I'd probably add an "anonymous user" to your roles list and use the role instead - that way you can also make it easier for the system to restrict what they can look at and divert them to the registration page if necessary. Rather than a null username and password, I'd use "New customer" and a blank password and let the role deal with what they need to do.
(It also reduces the work you have to do as you can just display the username on every page by the shopping basket without having to add an extra check for null values)


这篇关于有空信息是真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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