Wednesday, November 21, 2012

Normalization

Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency.


 am going to show you one simple E-R model database.
Student DetailsCourse DetailsResult details
1001   Ram               11/09/1986M4       Basic Maths                       711/11/2004       89           A
1002   Shyam           12/08/1987M4       Basic Maths                       711/11/2004       78           B
1001   Ram               23/06/1987H6                                                    411/11/2004       87           A
1003   Sita                16/07/1985C3        Basic Chemistry                 1111/11/2004       90           A
1004   Gita               24/09/1988B3                                                     811/11/2004       78           B
1002   Shyam           23/06/1988P3        Basic Physics                     13     11/11/2004       67           C
1005   Sunita           14/09/1987P3        Basic Physics                      1311/11/2004       78           B
1003   Sita                23/10/1987B4                                                      511/11/2004       67           C
1005   Sunita           13/03/1990H6                                                     411/11/2004       56           D
1004   Gita               21/08/1987M4      Basic Maths                         711/11/2004       78           B

In first look the above table is looking so arranged and well in format but if we try to find out what exactly this table is saying to us , we can easily figure out the various anomalies in this table . Ok let me help you guys in finding out the same.
  1. Insert Anomaly: We cannot insert prospective course which does not have any registered student or we cannot insert student details that is yet to register for any course.
  2. Update Anomaly: if we want to update the course M4’s name we need to do this operation three times. Similarly we may have to update student 1003’s name twice if it changes.
  3. Delete Anomaly: if we want to delete a course M4 , in addition to M4 occurs details , other critical details of student also will be deleted. This kind of deletion is harmful to business. Moreover, M4 appears thrice in above table and needs to be deleted thrice.
  4. Duplicate Data: Course M4’s data is stored thrice and student 1002’s data stored twice .This redundancy will increase as the number of course offerings increases.


A relation is in first normal form if the domain of each attribute contains only atomic values,


CustomerCustomer IDFirst NameSurnameTelephone Number123RobertIngram555-861-2025456JaneWright555-403-1659
555-776-4100789MariaFernandez555-808-9633

Customer
Customer IDFirst NameSurnameTelephone Number
123RobertIngram555-861-2025
456JaneWright555-403-1659
555-776-4100
789MariaFernandez555-808-9633


A design that is unambiguously in first normal form makes use of two tables: a Customer Name table and a Customer Telephone Number table.
Customer Name
Customer IDFirst NameSurname
123RobertIngram
456JaneWright
789MariaFernandez
Customer Telephone Number
Customer IDTelephone Number
123555-861-2025
456555-403-1659
456555-776-4100
789555-808-9633


There are no duplicate rows.




Neither of these tables can suffer from update anomalies.

No partial dependency exists between non-key attributes and key attributes.


Third Normal Form


all attributes that are not dependent upon the primary key must be eliminated.

Wednesday, November 7, 2012

Default Sqlyog.ini path

Default Sqlyog.ini  path 


C:\Documents and Settings\username\Application Data\SQLyog

Monday, November 5, 2012

Is left-join faster then inner join?

LEFT JOIN and INNER JOIN are different things. You cannot compare them.

If you write an INNER JOIN as LEFT JOIN you will either end up with
different results or - if you filter the NULL rows of the LEFT JOIN -
there is good chance for the LEFT JOIN to be slower. Because:

- the LEFT JOIN creates extra intermediate data (the NULL rows for
unmatched rows from the left table) that is thrown away later

- the optimizer has less freedom to optimize the LEFT JOIN

normalization concept

Normalization concept


The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).
First Normal Form
The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).
Second Normal Form
Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.
Third Normal Form






Sunday, November 4, 2012

APD

APD Install
-----------------------------------


extension=php_apd.dll
apd.dumpdir = "C:\xampp\tmp\traces"


Codeigniter

Learn Codeigniter

A. Installtion of Codeigniter

1. Download Codeigniter


2. Unzip , copy it htdocs folder

3. start apache and mysql

4. run index.php you will get be




B. Advantage of codeignighter


1.  CodeIgniter is Light Weight
2.  CodeIgniter is Fast
3.  CodeIgniter Uses M-V-C
4.  CodeIgniter Generates Clean URLs
5.  CodeIgniter comes with full-range of libraries
6.  CodeIgniter is Extensible
7.  CodeIgniter Does Not Require a Template Engine

others..
1.  Model-View-Controller Based System
2.  Extremely Light Weight
3   Full Featured database classes with support for several platforms.
4.  Active Record Database Support
5.  Form and Data Validation
6.  Security and XSS Filtering
7.  Session Management
8.  Email Sending Class. Supports Attachments, HTML/Text email, multiple protocols (sendmail, SMTP, and Mail) and more.
9.  Image Manipulation Library (cropping, resizing, rotating, etc.). Supports GD, ImageMagick, and NetPBM
10. File Uploading Class
11. FTP Class
12. Localization
13. Pagination
14. Data Encryption
15. Benchmarking
16. Full Page Caching
17. Error Logging
18  Application Profiling
19. Calendaring Class
20  User Agent Class
21  Zip Encoding Class
22. Template Engine Class
23  Trackback Class
24. XML-RPC Library
25  Unit Testing Class
26   Search-engine Friendly URLs

C. Make a first Program


Create a file at application/controllers/pages.php with the following code.


class Pages extends CI_Controller {

public function view($page = 'home')
{

}
}


Now you've created your first method, it's time to make some basic page templates. We will be creating two "views" (page templates) that act as our page footer and header.
Create the header at application/views/templates/header.php and add the following code.
header.php
<html>
<head>
<title><?php echo $title ?> Hello World</title>
</head>
<body>
<h1>Testings</h1>

footer.php
<strong>&copy; 2011</strong>
</body>
</html>




D. Adding logic to the controller


class Pages extends CI_Controller {

public function view($page = 'home')
{
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);

}
}


http://example.com/[controller-class]/[controller-method]/[arguments]



E. What is a Model?


Models are PHP classes that are designed to work with information in your database. For example, let's say you use CodeIgniter to manage a blog. You might have a model class that contains functions to insert, update, and retrieve your blog data. Here is an example of what such a model class might look like:


class Blogmodel extends CI_Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function get_last_ten_entries()
    {
        $query = $this->db->get('entries', 10);
        return $query->result();
    }

    function insert_entry()
    {
        $this->title   = $_POST['title']; // please read the below note
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->insert('entries', $this);
    }

    function update_entry()
    {
        $this->title   = $_POST['title'];
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->update('entries', $this, array('id' => $_POST['id']));
    }

}


F .Loading a Helper

$this->load->helper('name');






Thursday, November 1, 2012

SOAP

SOAP

There are two SOAP toolkits in common use on PHP. One is called NuSOAP. This works fairly well, but is no longer in active development (it was written before PHP provided its own built-in SOAP class). If you want to use NuSOAP, here is the official project web site



If you're using PHP5.2 or 5.3 (which you should be, since they're the only currently supported versions), then you'll have a built-in SOAP class. If you want to use the official PHP SOAP class, here's the manual page: http://php.net/manual/en/book.soap.php



If the service you're dealing with has a WSDL, PHP will automatically generate the appropriate methods for you when you create the object. For example:


$client = new SoapClient("http://somedomain/stockquote.wsdl");
print($client->getStockQuote("MSFT"));



$client = new SoapClient(null, array('location' => "http://somedomain/stockquote.asp"));
print($client->__soapCall('getStockQuote',"MSFT"));

About XML


XML


Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines rules for a specific type of document, including:
  • Names of elements, and how and where they can be used
  • The order of elements
  • Proper nesting and containment of elements
  • Element attributes
To apply a DTD to an XML document, you can:
  • Include the DTD's element definitions within the XML document itself.
  • Provide the DTD as a separate file, whose name you reference in the XML document.




An XML Schema describes the structure of an XML instance document by defining what each element must or may contain.XML Schema is expressed in the form of a separate XML file.



CDATA Sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. All tags and entity references are ignored by an XML processor that treats them just like any character data. CDATA blocks have been provided as a convenience measure when you want to include large blocks of special characters as character data, but you do not want to have to use entity references all the time.


eXtensible Stylesheet Language(XSL)  deals with most displaying the contents of XML documents.XSL consists of three parts: