is sql language really needed to c-like language to work with db

I have asked about this in ##php channel in FreeNode irc network. after i have said these my thoughts now i feel i have more right to learn sql. This is that talk in ##php with irrelevant said phrases, talked about other theme, deleted:
July 10 17:51:48 <qdb>    i do not understand why this additional sql layer is needed. cannot php s normal function and object interface work well with db?
July 10 17:52:07 <qdb>    for that i do not want to learn sql, like lazy
July 10 17:52:23 <Naktibalda>    qdb: use text files or some non-relational database 🙂
July 10 17:52:32 <Naktibalda>    they are popular now
July 10 17:53:06 <qdb>    Naktibalda, can you say that sql language can do something that normal if-then/for/functions/etc cannot do?
July 10 17:53:28 <Naktibalda>    qdb: than you have to implement database engine in PHP
July 10 17:53:29 <PoPSiCLe>    qdb: you need to actually… connect to some sort of DB…?
July 10 17:53:40 <qdb>    (or other people than Naktibalda )
July 10 17:53:54 <Naktibalda>    qdb: have you heard abour ORM?
July 10 17:54:14 <qdb>    Naktibalda, PoPSiCLe , for example, table is just an array ?
July 10 17:54:20 <qdb>    no
July 10 17:54:53 <Naktibalda>    http://en.wikipedia.org/wiki/Object-relational_mapping
July 10 17:55:00 <qdb>    may be object that has functions additional to normal access wby indexes
July 10 17:56:03 <Naktibalda>    qdb: http://www.doctrine-project.org/
July 10 17:56:07 <qdb>    yes that is the idea
July 10 17:57:36 <qdb>    but this mapping use sql inside them aren’t they?
July 10 17:57:42 <cythrawll>    yes
July 10 17:57:58 <Naktibalda>    qdb: you can’t edit database files directly without using SQL layer
July 10 17:58:07 <cythrawll>    because implementing the same stuff in php would be way slower and dirtier
July 10 17:58:09 <qdb>    i ask why they do not work directly with bytes i files without any sql layer
July 10 17:58:33 <Naktibalda>    qdb: http://couchdb.apache.org/
July 10 17:59:09 <cythrawll>    qdb, by the time you you get to that point where it’s as fast and efficient as a db, you have reinvented the db…
July 10 17:59:16 <PoPSiCLe>    lol
July 10 17:59:26 <Naktibalda>    qdb: you can work with files in php, but it’s much easier to use SQL
July 10 18:00:00 <Naktibalda>    you have to growup to the point where you understand that you really must to use database 🙂
July 10 18:00:45 <qdb>    Naktibalda, if there where built in database object that works with bytes in files directly, could not it be easier then using additonal language?
July 10 18:01:16 <cythrawll>    qdb, you would need a dsl to extract the data cleanly
July 10 18:01:21 <cythrawll>    and easily
July 10 18:01:25 <qdb>    dsl=?
July 10 18:01:40 <cythrawll>    sql is just a proven dsl that has worked well for years, why reinvent that?
July 10 18:01:46 <cythrawll>    qdb, domain specific language
July 10 18:02:09 <cythrawll>    their like mini languages, sql is an example of one.
July 10 18:02:13 <cythrawll>    regex is another
July 10 18:04:16 <qdb>    by the way in http://en.wikipedia.org/wiki/Domain-specific_language i have not seen that sql is mentioned for example though there are many languages mentioned
July 10 18:04:29 <Naktibalda>    qdb: short answer to your question is no
July 10 18:04:30 <cythrawll>    qdb, sql counts 😉
July 10 18:04:50 <Naktibalda>    programmer has to do more work with lower level database that doesn’t support SQL
July 10 18:05:45 <cythrawll>    qdb, I don’t see why you want to reinvent something difficult that’s gonna be slower and harder to use than a rdbms.
July 10 18:05:59 <qdb>    rdbms=?
July 10 18:06:03 <cythrawll>    instead of learn a simple as fsck mini language that has like 4 commands you use everyday
July 10 18:06:11 <cythrawll>    relational data base management system
July 10 18:06:24 <Naktibalda>    cythrawll: because he is too lazy to learn sql 🙂
July 10 18:06:35 <cythrawll>    Naktibalda, he’s too lazy to learn sql…
July 10 18:06:38 <cythrawll>    4 commands
July 10 18:06:44 <qdb>    has sql language so good features?
July 10 18:06:45 <cythrawll>    and rather make a flat file db
July 10 18:06:51 <archivist>    I would be lost without a database
July 10 18:06:53 <cythrawll>    which to make efficient would take years and years of work?
July 10 18:06:56 <cythrawll>    HAHAHAHA
July 10 18:07:10 <Naktibalda>    qdb: RDBS adds a lot of functionality, read about ACID
July 10 18:07:33 <Naktibalda>    http://en.wikipedia.org/wiki/ACID
July 10 18:07:33 <cythrawll>    <3 ACID
July 10 18:08:18 <cythrawll>    qdb, I would never mention that to perspective employers
July 10 18:08:21 <cythrawll>    1) you will never get a job.
July 10 18:08:49 <cythrawll>    2) workers will get no work done, when works get out, they’ll be literally on the floor laughing all day.
July 10 18:08:57 <cythrawll>    *when word gets out
July 10 18:09:20 <qdb>    ACID=Atomicity, Consistency, Isolation, Durability?
July 10 18:09:29 <Naktibalda>    yes
July 10 18:10:54 <uwjweq>    qdb: The isolation part is right. A good rule of thumb is, don´t drop acids.
July 10 18:13:23 <qdb>    Naktibalda, i am not against rdbms and acid
July 10 18:13:57 <qdb>    i say about alternative language instead of sql…
July 10 18:14:03 <qdb>    sql is in string
July 10 18:14:20 <qdb>    string operations are already slow
July 10 18:14:28 <Naktibalda> 🙂
July 10 18:15:16 <cythrawll>    qdb, well you don’t need to do operations on a string if you do it right.
July 10 18:15:36 <cythrawll>    at the most concatentation, which isn’t that slow.
July 10 18:15:52 <cythrawll>    and the whole language in a string is a weakness of PHP and other languages like it.
July 10 18:15:54 <qdb>    for example let you need sort table by age of user and get oldest 10 users. what is sql for that i do not know
July 10 18:16:21 <qdb>    but can think what it can be in php like language
July 10 18:16:26 <Naktibalda>    SELECT * FROM users ORDER BY age DESC LIMIT 10
July 10 18:16:31 <Naktibalda>    now write it in PHP 🙂
July 10 18:17:12 <cythrawll>    qdb, and it takes very little effort to learn.
July 10 18:18:15 <qdb>    myuserstable.getseveralorderedby(10,’age’);
July 10 18:18:28 <Naktibalda>    :))))
July 10 18:18:57 <cythrawll>    qdb, man the rest of that interface is going to be confusing and huge if it’s like that.
July 10 18:19:02 <Naktibalda>    qdb: it’s very specific function, SQL is general purpose query language
July 10 18:19:07 <cythrawll>    qdb, and he means implement it in PHP, not show a make believe interface.
July 10 18:19:32 <cythrawll>    qdb, your API docs is going to be harder to learn than SQL!
July 10 18:19:50 <Naktibalda>    btw, OOP calls are slow 🙂
July 10 18:20:43 <PoPSiCLe>    qdb: if you wanna make your own db / db-connection class, by all means go right ahead – but don’t do it for other than learning how to do stuff – don’t try to reinvent stuff that’s already been made pretty solid already
July 10 18:21:19 <Evil_Otto>    pdo++
July 10 18:21:20 <Naktibalda>    qdb: using ORM you can do something like Users:get()->orderBy(‘age’,’desc’)->limit(10)
July 10 18:22:00 <qdb>    why people do not make orm that does not use sql internally?
July 10 18:22:11 <Naktibalda>    qdb: because it’s impossible
July 10 18:22:27 <Naktibalda>    ok, enough for me. it’s time to stop feeding troll
July 10 18:24:56 <Naktibalda>    qdb: if you want to use non-SQL database, go and read about couchDB. I gave you a link before
July 10 18:25:03 <qdb>    ok
July 10 18:33:21 <qdb>    what does sql server when it gets SELECT * FROM users ORDER BY age DESC LIMIT 10 ? does not it just run ready getseveralorderedby(10,’age’) function which is in it? or it creates like compling new function for every type request? or does it such complicated function that get and use sql request as whole?
July 10 18:34:27 <JPT>    why are you interested in this? 🙂
July 10 18:34:59 <qdb>    JPT i just asked related question, did you see?
July 10 18:35:22 <JPT>    this is ##php… i don’t see any relation 🙂
July 10 18:35:41 <PoPSiCLe>    qdb: it takes the query fed to it, and executes it – the SQL language is self-sustained in that it interpretes SQL queries
July 10 18:35:55 <Naktibalda>    qdb: it does a lot of various and complicated tasks
July 10 18:36:27 <PoPSiCLe>    although the SELECT-statement could be made quicker by just selecting the table columns you need, instead of all columns
July 10 18:36:58 <qdb>    jpt, i asked  why php needs additional sql layer that need to be constructed in string and sent to sql server , not just use some objects and operators like that in php itself
July 10 18:37:13 <JPT>    oh…okay
July 10 18:37:59 <JPT>    i just thought you were asking about details within the mysql-server
July 10 18:38:01 <cythrawll>    qdb, because it was decided a long time ago, that a standard dsl was preferred rewriting the interface for every single db vendor in the world for every language.
July 10 18:38:28 <cythrawll>    qdb, and if that happened there would be a huge split in interfaces that it would become impossible to migrate from one vendor to the other.
July 10 18:39:02 <PoPSiCLe>    qdb: you send the SQL-query directly to the DBL – the SQL executes the query – I don’t see the big problem here – it wouldn’t really be quicker to have PHP do all the work
July 10 18:39:16 <cythrawll>    thanks to the SQL standard, even though there has been some minor diversions from it for each dbms, it’s difficult to migrate to different vendor’s but not impossible.
July 10 18:39:46 <Viper-7>    SELECT a.name as username, b.name as category_name FROM users a, categories b WHERE a.catid = b.id AND b.id IN (4, 7, 12, 14) OR MATCH (b.caption) AGAINST (‘+new’ IN BOOLEAN MODE)
July 10 18:39:54 <Viper-7>    sql can be really efficient for complex queries like that
July 10 18:41:40 <qdb>    Viper-7 thank you for an example where you say sql is really good , i want also try to replace that with php , cythrawll, because i am lazy to learn sql
July 10 18:41:56 <NoiseEee>    qdb: lazy people ruin life
July 10 18:42:10 <NoiseEee>    qdb: so off you go to ruin your own and not the channels
July 10 18:42:24 <Viper-7>    qdb: so instead you want to build your own database client api? rofl
July 10 18:42:34 <cythrawll>    qdb, it would be exponentially more work to replace that with PHP, than to learn sql
July 10 18:42:36 <cythrawll>    a lot more owrk
July 10 18:42:43 <cythrawll>    laziness has nothing to do with it I expect
July 10 18:42:56 <Naktibalda>    it’s not a laziness, it’s trolling
July 10 18:43:02 <Naktibalda>    looks too good 🙂
July 10 18:43:14 <oorza|werk>    You could always build around a persistent key-val storage daemon and build like a traditional app, with saved object states.
July 10 18:43:16 <cythrawll>    it’s gotta be trolling, I agree
July 10 18:43:19 <cythrawll>    no one is that thick.
July 10 18:43:41 <cythrawll>    oorza, like couchdb?
July 10 18:43:59 <PoPSiCLe>     cythrawll: you’d be amazed…
July 10 18:44:10 <oorza|werk>    cythrawll: either that or I was thinking memcachedb more specifically.
July 10 18:44:19 <oorza|werk>    It’d be exponentially more work, either way.
July 10 18:44:51 <qdb>    no, it is not only laziness  or trolling, i thought may be people just did not thought about that and there is some useful/valuable/priceful(?) idea
July 10 18:45:12 <PoPSiCLe>    not useful, not valuable – just silly and work-heavy
July 10 18:45:18 <cythrawll>    qdb, no one is gonna invest in something that’s gonna be more work for them.
July 10 18:45:38 <PoPSiCLe>    qdb: tried and tested > new, innovative and silly
July 10 18:45:52 <cythrawll>    qdb, such things have been tried many times before.  and guess what? everyone still uses sql databases
July 10 18:45:55 <oorza|werk>    Which is why frameworks are so popular, because they make things less work, despite the other costs 🙂
July 10 18:46:12 <Naktibalda>    cythrawll: isn’t key-value databases a hype now?
July 10 18:46:25 <cythrawll>    Naktibalda, it comes and goes.
July 10 18:47:07 <cythrawll>    they were the hype quite a few years ago to, they work for some problems, but kinda limited for real work
July 10 18:47:36 *    Naktibalda ушел (“leaving”)
July 10 18:48:19 <oorza|werk>    cythrawll: used in addition to SQL, key-val databases are quite useful, but yeah, to be useful, you do need the SQL db as well, at least in my experience.
July 10 19:57:19 <qdb>    Viper-7, you said an example: SELECT a.name as username, b.name as category_name FROM users a, categories b WHERE a.catid = b.id AND b.id IN (4, 7, 12, 14) OR MATCH (b.caption) AGAINST (‘+new’ IN BOOLEAN MODE) i have wrote php as i understand. is it correct? and could not it be as fast as sql server? and is it easy? i think it is easy:
July 10 19:57:33 <qdb>    foreach($users as $id->$catid){
July 10 19:57:33 <qdb>        if(($catid==4 || $catid==7 || $catid==12 || $catid==14) || $categories[$catid][$caption]==’+new’){
July 10 19:57:33 <qdb>            $oneresult[‘username’]=$users[$id][$name];
July 10 19:57:33 <qdb>            $oneresult[‘category_name’]=$categories[$users[$id][$catid]][$name];
July 10 19:57:33 <qdb>            $results[count($results)]=$oneresult;
July 10 19:57:33 <qdb>        }
July 10 19:57:33 <qdb>    }
July 10 19:57:35 *    ChanServ дал статус оператора канала  php-bot
July 10 19:57:35 *    php-bot забанил некоего %qdb!*@*
July 10 19:57:35 *    php-bot убрал права оператора канала с php-bot
July 10 19:58:21 <NoiseEee>    qdb: never paste code here. use a pastebin
July 10 19:58:34 <qdb>    Viper-7, have not you written an answer to me yet?
July 10 19:59:09 <qdb>    did not you see my php code?
July 10 19:59:31 <Viper-7>    qdb: the +new is a fulltext search, so it looks for the word new inside a large string, the php equiv would be preg_match(‘/\bnew\b/i’, $text), and yes, that whole set would be MUCH slower (probably to the tune of 30-40 times slower
July 10 20:02:50 *    ChanServ дал статус оператора канала  php-bot
July 10 20:02:50 *    php-bot убрал бан с %qdb!*@*
July 10 20:02:50 *    php-bot убрал права оператора канала с php-bot
July 10 20:09:50 <qdb>    Viper-7, thank you. i have seen that php-bot said to me that i am muted. did you see that i said “Viper-7, have not you written an answer to me yet?” and “did not you see my php code?”
July 10 20:12:24 <Viper-7>    qdb: yes, did you read my replies?
July 10 20:12:28 <qdb>    yes
July 10 20:12:32 <qdb>    one
July 10 20:12:34 <qdb>    …
July 10 20:12:49 <Viper-7>    qdb: what you have is a silly idea. doing it in raw C will still be slower, but fetching ALL the data first and doing it in php is just plain stupid
July 10 20:12:49 <qdb>    yes, one
July 10 20:13:02 <Viper-7>    one line, two points
July 10 20:13:15 <qdb>    Viper-7, i do not say about getting all data first!
July 10 20:13:26 <Viper-7>    qdb: to foreach over it you’d need it
July 10 20:13:30 <Viper-7>    and even without that
July 10 20:13:35 <Viper-7>    it would still be significantly slower
July 10 20:15:07 <qdb>    Viper-7, when php reads $users[$id][1] it should read only that from db file, $users is not array it is “arrayinfile”
July 10 20:15:35 <Viper-7>    qdb: ill say no more on it, as you’re clearly not listening to anyone.
July 10 20:15:52 <qdb>    ok
July 10 20:16:02 <qdb>    you said “to foreach over it you’d need it”
July 10 20:19:30 <qdb>    i think special foreach can be made for arrayinfile
July 10 20:19:56 <Viper-7>    qdb: and how do you find the user with a name ‘bob’ in that file? you have to read each line and check it
July 10 20:20:17 <Viper-7>    qdb: databases dont. they have indexes that allow them to search very quickly and accurately
July 10 20:32:38 <qdb>    Viper-7, foreachif($users as $oneuser , $oneuser[‘name’]==’bob’)
July 10 20:40:35 <qdb>    Viper-7, is that good? what problems can be with that syntax?
July 10 20:41:23 <Viper-7>    qdb: wheres $users come from? its an array of all the users in the system? so you load your entire list into an array first? …
July 10 20:41:37 <Viper-7>    qdb: and it wouldnt match “bob jane”
July 10 20:42:25 <qdb>    Viper-7, when php sees foreachif, it should give all its arguments do db driver
July 10 20:42:35 <qdb>    to db driver
July 10 20:43:10 <qdb>    to db driver of php which looks $users contents in db file
July 10 20:43:49 <NoiseEee>    qdb: i appreciate the laughs man
July 10 20:44:03 <Viper-7>    qdb: i give up, welcome to my ignore list, have fun failing
July 10 20:44:50 <cyth>    qdb is still here?
July 10 20:44:52 <cyth>    oh man
July 10 20:44:57 <Viper-7>    cyth: yep lol
July 10 20:45:09 <cyth>    like talking to a wall
July 10 20:45:10 <Viper-7>    cyth: and he hasnt progressed in the slightest
July 10 20:45:17 <cyth>    I thought for sure he’d be gone by the time my meeting was over
July 10 20:46:19 <qdb>    Viper-7, do not set me in ignore list of you. what is my own line?
July 10 20:46:35 <cyth>    qdb, think it’s too late for that.
July 10 20:46:53 <qdb>    drantin, what is my own line?
July 10 20:47:02 <Viper-7>    [02:44:32] <Viper-7> qdb: i give up, welcome to my ignore list, have fun failing
July 10 20:47:02 <Viper-7>    * Added qdb!*@* to ignore list
July 10 20:47:03 <qdb>    or it is not about me?
July 10 20:47:19 <oorza|werk>    haha Viper-7, awful ignore mask
July 10 20:47:28 <cyth>    learn2ignore
July 10 20:48:07 <Viper-7>    i did /ignore qdb
July 10 20:48:10 <Viper-7>    blame mirc 😛
July 10 20:48:14 <qdb>    ok…
July 10 20:48:31 <cyth>    Viper-7, mirc? o.O
July 10 20:48:33 <oorza|werk>    Viper-7: /ignore *!*@78.138.176.*
July 10 20:48:34 <oorza|werk>    :]
July 10 20:48:44 <cyth>    Viper-7, I thought you knew better :<
July 10 20:48:53 <Viper-7>    cyth: not on this pc 😛
July 10 20:49:13 <qdb>    do not ignore me!

One Comment

Leave a Reply