How databases work?
•Relational Databases: This is the most common database model that is used presently and others are hierarchical databases. In a relational database, data is stored in tables. The columns are called fields and the rows are called records. For purpose of use a database can have two fields: firstname and lastname. If you ass a record to this table, it happens to be ‘Sam’ and ‘John’.
In Relational Database each record of the table has to be an ID number that is said to be ‘primary key’. As Sam John record can have primary ID number 123. With this id number this data can be referred on to through other tables. For example if you are storing record of people’s orders you can have two columns like customer number and date. This allows you to simply store 123 and the date in the table each time Sam John orders to purchase something. And relational nature of the database would tell you that 123 is Sam John.
•SQL Databases: SQL here sands for ‘Structured Query Language’ and is used for generating queries from relational database as asking the database to find a record for you that matches criteria you specify. For example from firstname and lastname table for making queries following query syntax can be used.
INSERT INTO names VALUES (‘Sam ’, ‘John ’);
The ID number would be assigned automatically for the database. And to know for whom customer 123 relates following SQL can be run:
SELECT * FROM names WHERE id = ‘123′;
This would get us customer 123’s record from the database – Sam John. Below are mentioned some of the most common SQL queries.
•CREATE: Used to create new database tables. You have to tell the database which fields (columns) you want, and what kind of data (text, dates, etc.) each field is going to contain.
•SELECT: This command is employed for the purpose of searching table from the help of operators like = (equals), < (less than) and > (greater than) to find the record you’re after.
•INSERT: Let to add new records to the table.
•UPDATE: This allows making a modification and changing into the database and changing the data without having to delete and re-insert it.
•DELETE: To remove existing rows from the table employing the same basic syntax as SELECT.



Leave your response!