I have been told by some colleagues that the way I create databases is not practical.

Typically I will focus on the fields needed in the database and assign them VARCHAR(255) just to get myself up and running. Once the initial CRUD has been has been layed out and I begin to actually work with the data I will go back into MySQL and change the data type as needed. I understand that to some people going back and changing the data type may be considered a waste of time but its really not that difficult.

Typically I do this because my clients do not really know the exacts of their data requirements, its up to me to speculate what is required and implement it.

I dont see anything wrong with using VARCHAR(255) as a general catch all to get the application up and running. Can anyone share some opinion with me on this approach or possibly share with me your approach to data types when you are not sure what type of data you will be storing is?

有帮助吗?

解决方案

I think you're talking about VARCHAR fields... No one would add a BirthDate field using VARCHAR(255).

If I know that I need a field called NameI just add it as VARCHAR(n) and start working. I come back later to set its correct size if it's too big/small

其他提示

If your main goal is to get CRUD working, and then dial in the details later, I might suggest you research ORM "Object Relational Mapping" in the language you are using. An ORM is a library that wraps your calls into MySQL and returns objects instead of rows. This makes life easier because you don't focus on specific queries and instead focus on your data types. ORM's also make it easy to go back and change things after you've created them without a bunch of other code changes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top