PL-MYSQL BASIC
WHAT IS DATABASE PROGRAMMING?
Software that is used to manage data and information structured as fields, records and files.
A database program is the heart of a business information system and provides file creation, data entry, update, query and reporting functions.
DATABASE LANGUAGE
A Database language has Data Definition Language(DDL), which is used to construct a database.
Data Manipulation Language (DML), which is used to access a database.
DDL implements database schema at the physical, logical and external level.
DML provides the statements to retrieve, modify, insert and delete the data from the database.
IS SQL A DATABASE?
SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in a relational database.
All the Relational Database Management Systems(RDBMS) like MySQL, MS Access, Oracle, and SQL server use SQL as their standard database language.
SQL
Structured Query Language (SQL) is a domain-specific language used to manage relational databases and manipulate the data stored inside them.
Developers use SQL statements to perform tasks in SQL Server, MySQL, Oracle, Access, MatiaDB and PostgreSQL and other popular databases.
SQL LANGUAGE
DML:
Select, Insert, Update, Delete
DDL:
Create, Alter, Drop
DCL:
Grant, Revoke
TCL:
Begin, Tran, Commit, Rollback
DDL
A DDL is a language used to define data structures and modify data.
DDL or Data Definition Language actually consists of SQL commands that can be used to define the database schema.
It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database.
For example, DDL commands can be used to add, remove, or modify tables with in a database.
EXAMPLES
CREATE
is used to create the database or its objects (like table, index, function, views, store procedure and triggers).
DROP
is used to delete objects from the database.
ALTER
is used to alter the structure of the database.
TRUNCATE
is used to remove all records from a table, including all spaces allocated for the records are removed.
COMMENT
is used to add comments to the data dictionary.
RENAME
is used to rename an object existing in the database.
DML
A data manipulation language (DML) is a computer programming language used for adding (inserting), deleting, and modifying (updating) data in a database.
A popular data manipulation language is that of Structured Query Language(SQL), which is used to retrieve and manipulate data in a relational database.
EXAMPLES
INSERT
is used to insert data into a table.
UPDATE
is used to update existing data within a table
DELETE
is used to delete records from a database table
SELECT
this command reads and pulls out the records from the database.
There are two types of DML
PROCEDURAL
in which the user specifies what data is needed and how to get it.
NON-PROCEDURAL
in which the user specifies only what data is needed.
DCL
EXAMPLES
GRANT
gives user's access privileges to database.
REVOKE
withdraw user's access privileges given by using the GRANT command.
BASIC STRUCTURE OF SQL
The basic structure of an SQL expression consists of three clauses:
The select clause which corresponds to the projection operation. It is the list of attributes that will appear in the resulting table.
The from clause which corresponds to the Cartesian-product operation. It is the list of tables that will be joined in the resulting table.
The where clause which corresponds to the selection operation. It is the expression that controls which rows appear in the resulting table.
AGGREGATE FUNCTIONS
An aggregate is a collection of people who happen to be at the same place at the same time but who have no other connection to one another.
EXAMPLE:
The people gathered in a restaurant on a particular evening are an example of an aggregate, not a group.
AGGREGATE FUNCTION IS SQL
COUNT counts how many rows are in a particular column.
SUM adds together all the values in a particular column.
MIN and MAX return the lowest and highest values in a particular column, respectively.
AVG calculates the average of a group of selected values.
NULL VALUES
The SQL NULL is the term used to represent a missing value. A NULL value in a table is a value in a field that appears to be blank. A field with a NULL value is a field with no value. It is different than a zero value or a field that contains space.
If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.
A Null value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation.
Comments
Post a Comment