Dhananjay Kuber

Day 10 at rtCamp

Normalization

  • Normalization is the process to eliminate data redundancy and enhance data integrity in the table

  • Following are normal form

    • 1NF
    • 2NF
    • 3NF
  • 1st Normal Form

    • Every value must be atomic value
    • There must not be any multivalued attributes present in table
  • 2nd Normal Form

    • Table must be in 1NF
    • There must not be any partial dependency
    • All non prime attributes must dependent on prime attributes
  • 3rd Normal Form

    • Table must be in 2NF
    • Transitive dependency must not present in the table
    • Non prime attribute must not find prime attributes

SQL Joins

  • Inner Join
    • Inner Join returns all the records which are common in both the tables
SELECT * FROM customers
JOIN orders
ON customer.cid = orders.cid;
  • Left Join
    • Left Join return all data from left table and matched records from right table. The result will be null if no match found in right table
SELECT cid, cname, amt FROM customers
LEFT JOIN orders
ON customer.cid = orders.cid;
  • Right Join
    • Right Join return all data from right table and matched records from left table. The result will be null if no match found in left table
SELECT cid, cname, amt FROM customers
RIGHT JOIN orders
ON customer.cid = orders.cid;
  • Full Join
    • Full Join returns all rows from both tables regardless of whether there is a match between the columns used in the join condition
    • If there is no match, the result will contain NULL values for columns from the table that does not have a matching row.
SELECT *
FROM table1
FULL JOIN table2 ON table1.column = table2.column;

Magic Functions in PHP

  • __construct() and __destruct(): This methods are called when object is created and when script ends respectively
  • __set() and __get(): This methods are called when undefined property is accessed
  • __call() and __callStatic(): This methods are called when inaccessible method is called on object
  • __isset() and __unset(): __isset() is called when isset() is called on undefined property and __unset() is called when unset() called on undefined property