Friday, September 14, 2012

How to find files in a directory hierarchy that contain a string in Ubuntu

find . | grep 'string'
Search for files that contain string "string".

Wednesday, September 12, 2012

How to get the url of the current repository

git config --get remote.origin.url

Monday, August 13, 2012

How to get a form name from the twig-template in Symfony2?


It's pretty easy.
{{ form.vars.name }}

Friday, August 3, 2012

Relational Algebra Operations

How important is it to understand the relational algebra?

In the first place, the relational algebra is a part of computer science and so it should be useful thing ;)

Secondly, although the relational algebra is a formal model, it's the basis for database query languages. Widely used SQL is based on it. The study of the relational algebra is supposed to make the comprehension of SQL easier.

Foundations

First of all the relational algebra is a procedural query language. The word "procedural" means that the language consists of operations. The operations are performed on relations (tables or parts of them).

Relational Algebra Operations:

Wednesday, August 1, 2012

Using CASE in UPDATE statements

I believe you know the general way to write update statements. But let's revise and take a look at Figure 1.

If we want to update salary of the persons with salary over $50000, the query will look like this:

UPDATE Persons
SET salary = salary*2
WHERE salary > 50000;

We have just doubled salary for these persons!

Let's see a more interesting example. Suppose we want to increase salary for persons with salary over $60000 by 3 percent, whereas all others receive a 5% raise. We want to do that by executing only one(!) query.

Try to write the query by yourself before you look at the solution.

We can do it using case statement: