Rabu, 30 Desember 2015

About MySQL Databases and SQL Commands

About MySQL, Databases and SQL Commands

In the last post we ‘created
a database’
from our script as an example to test the working
of MySQL. Actually a database is a set of tables for storing data. The tables
in a database may be logically related with each other. MySQL supports unlimited
number of databases and for each application you may use a different one

To understand relation between a database and tables consider an example of
a database oriented Note
Keeping application
. Since it needed user authorization we can store
user information such as username and password in one table, upgrading that
system to multi-user capable is also possible because a table can store any
number of rows (i.e. different set of username & password, in this case).
We’ll also need a second table for storing note data. Thus we’re
using a database having two tables to store data related to a single application.

The following image illustrates this relation quite well:

How tables are organised in a database


MySQL database server supports the creation, storing and retrieval of data using
the Structured Query Language. SQL is quite easy to understand and work with,
probably because it is very much plain English. Below I’m stating a few
useful SQL commands:

1. CREATE DATABASE

It creates a database named ‘temp’. We discussed about it in the
post Installing,
Configuring and Testing MySQL Database Server on localhost


2. CREATE TABLE

It creates a table inside a database. The database to be worked with should
first be selected using the following PHP command:

$db->slelect_bd($dbname);

it could be run after first creating the database through a SQL query. After
selection of database the following SQL query will create a table inside that
database (since a table is not an independent entity).

CREATE TABLE one (id INT, name VARCHAR(20));

The above query creates a table ‘one’ with two data fields id of
type integer and name of type character (20 characters long). This table can
hold any number of data.

3. INSERT INTO

After creation of table we can insert data into it with the following SQL query:

INSERT INTO one (id, name) VALUES (1,’PHP’);

4. SELECT

It is used to request data form a table.

SELECT * FROM one;

It will request all (*) the rows from the table ‘one’.

NOTE: Though SQL commands end with a ‘;’ semicolon, you don’t
have to have it when querying database from PHP. SQL commands from PHP works
both in UPPER and lower case.

Previous Articles:

Read More..

Selasa, 22 Desember 2015

Heap Sorting method and algorithm

In heap sorting process:

First of all organizing the whole data to be sorted as a binary tree i.e. heap. And after that impletment heap sorting.

Step 1: (How to data organizing as binary tree?)

Remember only 2 rule:

Rule:1.

The parent node must be greater then child node.
If parent node is not greater then to child node not replace it with parent node. And if binary tree is large then, if relaceing child node(now its parent node) is greater then to great-parent node then its also is replace the great-parent node.

Rule:2.

New element always insert in left side and after right side of parent node.
If left side of parent element has already element then new element would be insert in right side. And if right side of parent node has already element then new element will be insert in left side.

Step 2: (How to perform heap sorting:)

Remove the topmost element(largest element) and replace it with the rightmost element.

Step 3:

Repeat steps 1 and 2 untill all elements is not sorted.



Heap Sorting method/process by example:

max heap : 80 , 32 , 31 , 110 , 50 , 40 , 120 

Step1:
                  80

Step2:  
                 80
              /      
           32        31

Step3:  
                 80                           80                         110
              /                            /                         /      
           32         31    ==>     110       31     ==>    80         31
          /                             /                            /
     110                           32                          32


Step4:
                 110
               /      
            80        31
          /            
      32       5


Step5:
                  110                               110
                /                                /      
             80         31    ==>          80        40
           /           /                     /         / 
        32      50   40                32      50   31



        
Step6:
                 110                               110                                120
               /                                /                                   /      
           80         40       ==>        80          120      ==>        80         110
         /          /                    /            /                     /          /    
     32       50   31   120         32     50    31     40           32     50  31       40

-------------------------------------------------------------------------------------

(1)
                  120 [1]
                 
              /                

          80 [2]               110 [3]

      /                      /          

 32 [4]       50 [5]     31 [6]         40 [7]

// [1],[2],[3],[4],[5],[6],[7]: Index number 
// Now applying step 2(perform heap sorting)
// Replace the topmost element with the rightmost element.


(2)
             40                                     110      
           /                   Heaping        /      
        80       110        =====>     80          40
      /         /                         /           /    
   32     50   31    120              32     50   31    120

(3)
//now replace 110 with rightmost element i.e. 31 because 120 had been sorted.

            31                                        80                                 80
         /                 Heaping             /              Heaping         /      
       80        40        ======>        31         40      ======>    50       40
     /         /                             /          /                       /         /  
   32   50  110   120                  32     50   110    120           32    31  110  120

(4)
//now replace 80 with rightmost element i.e. 31 because 110, 120 had been sorted.

           31                                           50                                    50
         /                   Heaping              /                   Heaping         /    
       50       40          ======>         31          40        ======>    32      40
      /          /                             /           /                       /         /    
   32     80  110  120                    32     80     110    120           31     80  110   120

(5)
//now replace 50 with rightmost element i.e. 31 because 80, 110, 120 had been sorted. 

              31                                      40

           /                    Heaping         /      
       32           40        ======>    32         31
     /            /                         /         /    
   50     80    110    120             50     80  110    120

(6)
//now replace 40 with rightmost element i.e. 31 because 50, 80, 110, 120 had been sorted. 


              31                                     32
            /               Heaping            /    
         32      40        ======>        31       40
       /         /                           /         /    
    50   80   110   120               50    80   110    120

(7)
//now replace 32 with rightmost element i.e. 31 because 40, 50, 80, 110, 120 had been sorted. 

                   31
                /      
            32        40
         /           /      
     50     80   110    120

Now all elements are sorted: 31 , 32 , 40 , 50 , 80 , 110 , 120

Related programs:

  1. Merge sorting
  2. Heap sorting
  3. Bubble sorting
  4. Selection Sorting
  5. Insertion sorting
  6. Insertion sorting using function
  7. Shell sorting
  8. Quick sorting
  9. Radix sorting
  10. Liner sorting
Read More..

Sabtu, 19 Desember 2015

By Bonnie Contreras


It always is disturbing to see individuals going for the wrong hard drive shredding Austin despite the fact that a lot of information on how to get outstanding ones is available. There are those who think that they know what to do yet they comprehend almost nothing. To avoid such a aspect happening to you, you must know the factors that must be considered when in need of such alternatives.

These alternatives are often found with a lot of comfort in almost every position on the world. This has been connected to the aspect that many more individuals are coming up to offer. You therefore can predict finding someone offering them without even having to look too far. This probably is something that clients should be very pleased about.

What is important to note is that many individuals get confused by the many options instead of using them to get better results. For example, some of them even think that anything that comes their way is outstanding. This is the purpose they just choose some options without even understanding what they are getting into. Of course, this is the beginning of many problems.

Seasoned clients know that even though there always are many options that they got to create, not everything that comes their way can be outstanding. This is the purpose why they evaluate effectively the importance of everything before they choose. They do not want to get their useful cash on factors that do not even add any value to their way of life.

It is outstanding to know exactly what you need. When it comes to this, you will be surprised to know that individuals have absolutely different goals on their ideas when they start looking for these alternatives. What actually you think is the best for you maybe nowhere on the mind of another personal looking for the same aspect. You therefore must comprehend your needs.

So as to get the most appropriate ones from among the many options available, you should evaluate their importance. Just take a look at what every professional can do and how they be existing at to their clients. Even though you may not be able to talk about to all of them, you will discover it much much easier to create a wiser choice and therefore end up with outstanding alternatives.

This can be a lot easier when you have some information. For new clients, there is no way that a personal can create options without even understanding what they are analyzing. In this scenario, just try to talk about to some of the individuals who have used the alternatives before and discover out out what they have to say. Online views are also a very effective way of understanding all that relates to these alternatives.

You however should not neglect to go for quality because that is what determines the suitability of hard drive shredding Austin. It is confusing to notice that some individuals do not even appropriate fear about top great quality yet it effects everything. If you want to pay less, just compare costs.




About the Author:



Read More..