Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How important is database normalization in a very simple database?

I am making a very simple database (mysql) with essentially two types of data, always with a 1 to 1 relationship:

Events

  • Sponsor
  • Time (Optional)
  • Location (City, State)
  • Venue (Optional)
  • Details URL

Sponsors

  • Name
  • URL


Cities will be duplicated often, but is there really much value in having a cities table for such a simple database schema?

The database is populated by screen-scraping a website. On this site the city field is populated via selecting from a dropdown, so there will not be mistypes, etc and it would be easy to match the records up with a city table. I'm just not sure there would be much of a point even if the users of my database will be searching by city frequently.

like image 481
Baa Avatar asked Dec 02 '25 08:12

Baa


2 Answers

Normalize the database now.

It's a lot easier to optimize queries on normalized data than it is to normalize a pile of data.

You say it's simple now - these things have a tendency to grow. Design it right and you'll get the experience of proper design and some future proofing.

like image 156
Broam Avatar answered Dec 03 '25 23:12

Broam


I think you are looking at things the wrong way - you should always normalize unless you have a good reason not to.

Trusting your application to maintain data integrity is a needless risk. You say the data is made uniform because it is selected from a dropdown. What if someone hacks on the form and modifies the data, or if your code inadvertently allows a querystring param with the same name?

like image 26
D'Arcy Rittich Avatar answered Dec 03 '25 22:12

D'Arcy Rittich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!