tags:

views:

79

answers:

6

I am starting new project. In my project I will need to use local provinces and local city names. I do not want to have many mysql tables unless I have to have or csv is fast. For province-city case I am not sure which one to use.

I have job announcements related with cities, provinces. For Csv case I will keep the name of city in announcements table, so when I do search I send selected city name to db in query.

can anyone give me better idea on how to do this? csv or mysql? why?

Thanks in advance.

+2  A: 

If you use CSV you will run into problems eventually if you are planning on a lot of traffic. If you are just going to use this personally on your machine or with a couple people in an office then CSV is probably sufficient.

jarrett
+2  A: 

I would recomend keeping it in the db. If you store the names in the annoucements table, any changes to the csv will not be updated in the queries.

DBs are meant to hanle these issues.

astander
+3  A: 

Database Pros

  • Relating cities to provinces and job announcements will mean less redundant data, and consistently formatted data
  • The ability to search/report data is much simpler, being [relatively] standardized by the use of SQL
  • More scalable, accommodating GBs of data if necessary
  • Infrastructure is already in place, well documented in online resources

Flat File (CSV) Pros

I'm trying, but I can't think of any. Reading from a csv means loading the contents into memory, whether the contents will be used or not. As astander mentioned, changes while the application is in use would be a nightmare. Then there's the infrastructure to pull data out, searching, etc.

Conclusion

Use a database, be it MySQL or the free versions of Oracle or SQL Server. Basing things off a csv is coding yourself into a corner, with no long term benefits.

OMG Ponies
+1  A: 

If you don't want to use a database table, use an hardcoded array directly in PHP: if the performances are so critic I don't know any way faster than this one (and I don't see a single advantage in using CSV too).

Apart of that I think this is a clear premature optimization. You should make your application extensible, especially at the planning stage. Not using a table will make the overall structure rigid.

ntd
+1  A: 

While people often get worried about the the proliferation of tables inside a database they are under management. Management by the DBMS. This means that you can control the data control task like updating and it also takes you down the route of organising the data properly, i.e. normalisation.

Large collections of CSV or XML files can get extremely unwieldy unless you are prepared to write management systems arounf them (that already come with the DBMS for, as it were, free).

There can be good reason for not using DBMS's but i have not found many and certainly not in mainstream development.

PurplePilot
A: 

Thanks guys for answering. I guess I could not make myself veery clear. I will use DBMS for my regular tables but for only province and city names I do not want to have one more table, because those information will never change and too big to have it hardcoded. To less number of tables, code files I have the less messy will my project be. That is why I asked this question. May be I am wrong?

ubuntus
Why are you concerned about the number of tables? As long as the rest of the database is well-structured one more or one less table will not change anything. Or am I missing something here?
shylent
OMG Ponies