Saturday 26 January 2013

Database Normalization and Types of Normalization

  • what is normalization and types of normalization 1NF 2NF 3NF with examples SQL simple definition of normalization

Normalization is the techinque of designing the database with the least redundancy and duplicacy of data. 


  • Types of Normalization:
    • First Normal Form
    • Second Normal Form
    • Third Normal Form
    • BCNF - Boyce Code Normal Form
    • Fifth Normal Form
    • Sixth Normal Form : Impossible to achieve this level of normalization
  • First Normal Form
    • Eliminate repeating groups in individual tables. 
    • Create a separate table for each set of related data. 
    • Identify each set of related data with a primary key.
    • Example :  
             Lets Consider Unnormalized table 




Tables should have only two dimensions. Since one student has several classes, these classes should be listed in a separate table. Fields Class1, Class2, and Class3 in the above records are indications of design trouble. 

 Spreadsheets often use the third dimension, but tables should not. Another way to look at this problem is with a one-to-many relationship, do not put the one side and the many side in the same table. Instead, create another table in first normal form by eliminating the repeating group (Class#), as shown below:


  • Second Normal Form
    • Create separate tables for sets of values that apply to multiple records. 
    • Relate these tables with a foreign key.
    • Example :
Note the multiple Class# values for each Student# value in the above table. Class# is not functionally dependent on Student# (primary key), so this relationship is not in second normal form.

The following two tables demonstrate second normal form:

                 Students :


                  Registration:


  • Third Normal Form
    • Eliminate fields that do not depend on the key.
    • Example :
In the last example, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below:

                  Students :


                   Faculty :



Difference between DBMS and RDBMS

  • database management system vs relational database management system /
Database Management System VS Relational Database Management System

• Relationship among tables is maintained in a RDBMS whereas this not the case DBMS as it is used to manage the database.

• DBMS accepts the ‘flat file’ data that means there is no relation among different data whereas RDBMS does not accepts this type of design.

• DBMS is used for simpler business applications whereas RDBMS is used for more complex applications.

• Although the foreign key concept is supported by both DBMS and RDBMS but its only RDBMS that enforces the rules.

• RDBMS solution is required by large sets of data whereas small sets of data can be managed by DBMS.

Wednesday 16 January 2013

How to know request is ajax or other in php


How to know whether the request is an ajax request or normal request in PHP? 

We can know it through following code:

$ajax false;

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
 $ajax = true;
}
echo $ajax;

Wednesday 2 January 2013

All Gmail Shortcuts

First enable shortcuts of gmail
for that go to setting and find Keyboard shortcuts and on it

Jumping
g then i : Go to Inbox
g then s : Go to Starred conversations
g then t : Go to Sent messages
g then d : Go to Drafts
g then a : Go to All mail
g then c : Go to Contacts
g then k : Go to Tasks
g then l : Go to Label

Threadlist selection
* then a : Select all conversations
* then n : Deselect all conversations
* then r : Select read conversations
* then u : Select unread conversations
* then s : Select starred conversations
* then t : Select unstarred conversations

Navigation
u : Back to threadlist
k / j : Newer/older conversation
o or <Enter> : Open conversation; collapse/expand conversation
p / n : Read previous/next message
` : Go to next inbox section
~ : Go to previous inbox section

Application
c : Compose
/ : Search mail
q : Search chat contacts
. : Open "more actions" menu
v : Open "move to" menu
l : Open "label as" menu
? : Open keyboard shortcut help

Actions
, : Move focus to toolbar
x : Select conversation
s : Rotate superstar
y : Remove label
e : Archive
m : Ignore conversation
! : Report as spam
# : Move to trash
r : Reply
<Shift> + r : Reply in a new window
a : Reply all
<Shift> + a : Reply all in a new window
f : Forward
<Shift> + f : Forward in a new window
<Shift> + n : Update conversation
<Tab> then Enter : Send mail
<Esc> : Focus last mole
] / [ : Remove conversation from current view and go previous/next
} / { : Archive conversation and go previous/next
z : Undo last action
<Shift> + i : Mark as read
<Shift> + u : Mark as unread
_ : Mark unread from the selected message
<Ctrl> + s : Save draft
+ or = : Mark as important
- : Mark as not important
g then p : Make a phone call
<Shift> + t : Add conversation to Tasks