Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As the size of my data and the structures I use to hold it get larger and more complex, I start to wonder if I should learn to use sql databases. In the past, instead of unique tables, I would do something like the following:

'class Dog
       String name
       Toy[] toys
       long  numberOfHairs
       short numberOfFlees
       etc.

Then I might have a sorted array based on numberOfFlees, a hash of names, a set of toys, etc. to suit my needs. This has worked fine for me with smaller projects, but at what point should I consider SQL. What will I lose and gain?

share|improve this question
    
Have you read up on the feature set of most database? Locking, transactions and concurrency management, to start with? Until you read the entire feature set of typical databases (Oracle, MySQL, PostgreSQL) this question is too vague to answer. –  S.Lott Apr 22 '11 at 2:22
    
Don't forget to add NoSQL to the list as those types of databases bring their own set of features to the table. –  R0MANARMY Apr 22 '11 at 5:28

3 Answers 3

If you will be paying your bills via programming then at some point you will need to at least learn the basics of SQL databases. You might as well do a bit of reading on it now and get the ball rolling. That said, with all of the layers of abstraction used these days, you might never actually call one directly but it is valuable to understand why they are used and what it is doing.

Advantages

  • Data is persisted beyond the running application
  • Access to the data can be tightly secured
  • Extremely efficient at manipulating large data sets
  • Data can be shared between different applications running at the same time
  • Etc., Etc.,
share|improve this answer

I would consider storing anything more complicated than a .properties file or simple delimited file (e.g. CSV) as time to consider SQL or some other storage/retrieval abstraction mechanism depending on the data (e.g. XML binding, LDAP). SQL is great for storing large amounts of relational (hence the name) data and allowing efficient searching/sorting/joining on multiple fields.

The Toy[] toys array in your example is a place where SQL can shine. It's trivial to get a list of all Dogs who like a particular Toy without having to scan all of dogs[x].toy[y]. How about sorting the dogs breed's by the average cost of that breed's toys?

There are many ORM tools that make SQL data binding easy(er). If you intend to learn one I would suggest learning a bit of SQL first so you understand the basic concepts better when applying the ORM.

share|improve this answer

obviously if you product have to deal with big amount of data (not a few dozens records) you need a database just for performance reasons.

however besides performance or coding issues there is one very important factor that needs to be taken into account - value of the data. I'd apply following rule: if the data is more important than your software - use decent database.

so with SQL if expected size of your database is something like thousands records you won loose anything with. Your gain will be reliable data storage w/ nice performance

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.