Relational DBMSes

There is a table of two fields, primary key integer ID and
char(50) VALUE. Before adding the unique index to it, you need to
know, if there are duplicated VALUEs in the table. How you will do it?

Ans: should check the primary key integer is repeating in the
primary key field. If any one value from the field returning the
count greater than 1, we can not add unique index to the the field

What's the difference between INNER JOIN and OUTER JOIN? What
other types of JOINs do you know?

Ans : The INNER JOIN takes data from both tables returns the
specified data exists in both tables. But the OUTER JOIN check both
tables and returns values from the outer table when the criteria mets.


What is a VIEW? What are the advantages and disadvantages of views?

Ans : View is a representation of a sql statement stored in
memory, which can be easily reusable.
Advantages of views:
we can view the data without storing the data into the object.
We can restict the view of a table i.e. can hide some of columns
in the tables.
We can Join two or more tables and show it as one object to user.
Disadvantages of views
we can not use DML operations on views.
When a table is dropped view will becomes inactive.. it depends on
the table objects.
It is an object so it occupies space

What's the main difference between WHERE and HAVING?

Ans: WHERE is a single row function, where as Having is based on groups.
When we use having Having we should use the Group by keyword.

What are subqueries? Does MySQL support them?

A query that is used within another query. For example a
select-statement within the WHERE or HAVING clause of another SQL
Mysql supporting the subquery system.

please complete the questions through the comments



PHP Question and answers

Do you need to initialize the variable before its usage? Why?

Ans: Actually, Its not mandatory in php. But its recommended to
initialize variable before its usage. In most of the servers the the
error reporting for display notices are disabled. In the case of
servers which enabled error reporting on for notices, its highly
recommended to initialize variable before its usage.

How do you use a function's parameters inside the function?

Ans: Information are passed to the functions as parameters
separated by commas. We can handle these parameters in several ways.
We can pass variables into the function
We can pass arrays to the function
We can set default argument values in the function parameters.

There are two non-empty arrays $a and $b. What is the result of their sum (+) ?

Ans: it will return the value of $a (the first array);

Comment the following code: $q = 'SELECT * FROM mytable WHERE id = ' . $_POST['id'] ? Is there any possibility to make it better?

Ans: $q = 'SELECT * FROM mytable WHERE id = ' . htmlentities ( mysql_real_escape_string ( $_POST['id'] ) );

How do you swap the values of string variables $a and $b, without using a third variable?
Ans : $a = "content";
$b = "not a content";
list($a,$b) = array($b,$a);
echo "new a is - ". $a;
echo "
new b is - ".$b;

What way will you choose to sort the array of strings?

Ans: Will use asort() function.

What methods can you use to start a PHP block? Which is best,and why?

Ans: we can use tags
<% %> tags
The best on is tag. Because its the default code block
of php. It works on all servers , no need to edit the php.ini settings
in the server. The other blocks are referred as short tags. Its server
specific, needs to edit in the php.ini settings to activate them.

Will be the value of $a after the execution of the following line of code: $a = include 'somefile.php'; ?

Ans: It will execute the script in it

Describe the advantages and disadvantages of the various ways of configuring a Web server to process PHP scripts.

Ans: Please post your the answer as comments below

What are the sessions. How is sessions data stored at the server?

Ans: Session is defined as the instance between when a user starts a
requests to a particular webserver and closing the requests to that
These informations can stored server based on the session ids. We can
store these informations on the server in its local memory, files, or
in the databases.