#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    75
    Rep Power
    2

    What makes query language tough?


    I'm studying Intro to databases and I'm surprised how tough querying can be sometimes.
    I wonder what makes it tough?

    Is it the language constraints? Or is it because it is too strict and formal?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    Well, I think I know about 50 languages and use about 10 of them regularly - and I could not agree SQL is tough.

    On contrary many people with only basic knowledge of programming and web-design feel themselves comfortable enough with SQL.

    So I fear the main reason is the lack of the relevant experience. However there are good news - as you practice, this problem will vanish.

    It is not easy to become guru of databases and SQL because its depths are really unfathomable, however for novice it does not matter.
    CodeAbbey - programming problems for novice coders
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    that's a pretty ... vague question. You might as well ask us why machines are sometimes so complex.

    Are we talking about SQL here? Can you give an example of what you consider to be complex?

    There are all kinds of reason for why people may say that a query is complex. Sometimes the task is complex. When you aggregate data from all kinds of sources or deal with complicated logic, it's only natural that the query will be complex as well. The language may also play a role. SQL is rather cumbersome, because every association has to be established with a join. This way you quickly end up with large queries for rather trivial data. And the perceived complexity depends on your experience. Since you're new to databases, it's not too surprising you find things hard to understand at first.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    75
    Rep Power
    2
    I'll try to be specific.
    I'm talking about general query languages. Till now I've learnt three - relational algebra, relational calculus and MySQL.

    Let me explain what I mean by tough - A query like find employees who work on all projects controlled by Department 5 (from my book) requires some thinking.
    If we think informally, it seems so simple. Just check projects of all employees, if they match with that of department 5 then yes, else no.

    When we actually write down query for this question, it seems a bit harder. You have to think a bit, right?
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    You have to think a bit, right?
    But you forget that the "everyday reasoning" was not the thing which you possess from birth. The same with, for example, English language. Some people learn it from childhood and did not think it is tough. Other people learn it in school or university - and they may say the language is far not easy.

    So it is just the matter of practice - to get used to reasoning in the machine way.

    The human brain works not the same way machines do, that is why we may misjudge the complexity or toughness of problems. For example for us looks not big deal to select the tallest man from group or to recognize people by face - while for computer the first task requires at least a loop through all the group and the second is so complex that it could be effectively programmed only by high-paid specialists (while the same task is easily solved even by the baby who hardly learned to speak).
    CodeAbbey - programming problems for novice coders
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,785
    Rep Power
    348
    Originally Posted by Avichal
    Till now I've learnt three - relational algebra, relational calculus and MySQL.
    MySQL is not a "query language".
    It's a relational database management system which happens to use (a variation of) the query language "SQL".

    When we actually write down query for this question, it seems a bit harder. You have to think a bit, right?
    Well that's true for any problem you have to solve: you need to think about it.
    Whether that is a SQL query, a programming assignment, fixing the tires of your bicycle or baking a cake - you should always think before you do something.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    The problem is that you're obviously used to thinking procedurally: Do this, take that value, compare those values.

    SQL and all other languages you've mentioned are declarative. This is a different way of thinking. It's not more complex, just different.

    This is like learning a foreign language. If English is your native language, and you encounter French for the first time, you'll find it weird and difficult to understand. That doesn't mean French is actually more difficult than English. In fact, the French will probably claim the exact opposite.

    Unfortunately, nowadays people are living in a bubble of procedural programming. At school or in university, you learn Java, C, Python or whatever. At home, you learn PHP or so. That's it. Of course SQL is a huge gap then. But if you're willing to learn something new and try out new languages, you'll realize that "the SQL way" isn't weird or complex at all.

    Also note that MySQL isn't exactly a good representative of SQL the language. It lacks many fundamental features of SQL and requires a lot of workarounds. So just because something is complicated in MySQL doesn't mean that "SQL is bad".
    Last edited by Jacques1; November 22nd, 2013 at 03:44 AM.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo