Dav*_*veB 5 database sql-server database-design data-structures
常用的字符串数据存储类型是否有任何推荐的字段大小?例如FirstName,LastName,AddressLine1,AddressLine2,City,State,PostalCode,EmailAddress等等.我相信任何创建表来存储这些常用数据字段的人都必须决定使用哪个最大大小.
你重视什么?
您是否有某种用于做出决定的公式(例如所有字段大小是8的倍数)?
贵公司是否有指导方针,因此包含这些字段的所有表格都是统一的?
这只是个人的事吗?
我知道如果我有一个固定的标准,我就不必停下来思考它并最终得到不同大小的字段.在UI上工作时,这种一致性也会很好,因为在输入字段和任何数据验证代码上设置maxlength会更容易.
Keep in mind that the US Postal Service only allows for lines of 40 characters. Thus, 173438 Martin Luther King Memorial Parkway SE, Suite 1124 would be converted by a CASS application into something like:
173438 Martin Luther King Pkwy SE
Suite 1124
Run Code Online (Sandbox Code Playgroud)
For addresses, I would start with the USPS guidelines and then if you plan on supporting international clients, look at those country's postal standards. If the address is never going to be queried, filter, sorted or used on an actual letter, then you might as well make a single column typed as nvarchar(max) (BTW, this never ends up being the case and thus I always end up needed separate columns for city, state, postal code etc).
Of late, I have gotten out of the habit of using individual columns for the lines of a street address. Instead, I use a single nvarchar(max) and split on line break (\r\n or just \n). In this way, I don't have to add a new column when one user wants a five line address excluding the city, state and postal code.
我通常使用 nvarchar(25) 作为名称。我还没有遇到过名字的一部分长度超过 25 个字符的人。我并不是说这是不可能的,我只是从未在现场环境中见过它。