开发者

Is it ok to store postal addresses as one text field, rather than street1, street2, etc.?

I need to store postal addresses for my users, but I don't plan on really doing much with these addresses other than displaying it (won't be searching users by location or anything). In this scenario, is it ok to just开发者_C百科 have an addresses table which holds an address id, user id, and one text field where users can enter in the data anyway they want? Thx for your time!


Sure, it's ok to use a single column to store an entire address, as long as all these criteria apply to you and your app.

  1. You don't care what users put in there. (Some wiseass will surely put "Cthulhu and I had some good times".)
  2. Your app doesn't try to take apart the values in that column. (In relational terms, the dbms is either supposed to ignore internal structure in a column or provide functions to manipulate that structure. Internal structure here might include street name, city, state, ZIP code, and so on. Functions include things like the functions SQL dbms provide to take apart dates and timestamps.)
  3. You won't select or sort by part of the column. (This is essentially the same thing as number 2, above.)
  4. You can afford the significant cost (in both money and time) of fixing all that data should your app require it later.


The data is only as valuable as you make it.

  • Is it possible the application will grow and new features will be implemented demanding better address handling?
  • Will you ever want to produce a mailing list of any sort? Mailing houses will dislike the proposed format.

If you perform no validation, and the string is used for display purposes only, then go for it. But consider that the time and cost to implement proper validation and field separation now might pay off big time in the future.


Yes you can do this if you are absolutely sure you dont need to search or validate any part of the address. It will work fine for data storage and retrieval just as well as splitting it out


If all you're doing is displaying these addresses then I think it's perfectly fine. Just remember to insert things into your database securely!


Sure, no reason you couldn't, just make sure to test your user input data to avoid any potential problems down the road.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜