Tuesday, June 10, 2014

SQL basic

Data: are the raw facts and figures which can be recorded.

for eg, name of the student, course details, fees details etc.
        ABEL, JAVA, 10000

Information: are the processed data or organized data which gives complete meaning.
for eg, Abel learning Java course and paid 10000 towards fees.
      
Database: is a logical collection of relevant data.
for eg, university database, railway database etc.

DATABASE MANAGEMENT SYSTEM(DBMS): It is collection of programs or software
which manages the database.

Data is stored in files (.dbf)

Benefits of the Database Approach
• Redundancy can be reduced
• Inconsistency can be avoided
• Data can be shared
• Standards can be enforced
• Security restrictions can be applied
• Integrity can be maintained


Keys:
KEY : IS A ATTRIBUTE WITH WHICH WE CAN UNIQUELY IDENTIFY EACH ROW IN THE TABLE.

Natural Key: A natural key is one or more existing data attributes that are unique
to the business concept. For the Customer table there was two candidate keys, in
this case CustomerNumber and SocialSecurityNumber. 

Surrogate key: Introduce a new column, called a surrogate key, which is a key that
has no business meaning.

primary key= It is attribute/attributes which will not allow to store the null
value and duplicate value, it is also useful to identify each row uniquely in
the table. NOT NULL + UNIQUE (The minimal candidate key is known as primary key).

candidate key = are the attributes(COLUMNS) which can qualify for the primary key.

alternate key -> the remaining candidate key which can qualify for the primary key,
but it is not primary key.

foreign key -> It is the attribute/attributes whose characteristic is dependent on
the characteristic of another atrribute/primary key attribute. foreign key column
can have only those value which is there in the primary key column and it can have

null values, it can have duplicate values also.

relational database: collection of related/relevant data stored in tables(collection
of relations(tables) or two-dimensional tables).

RDBMS - Relational DataBase Management System
is a software or collection of programs which manages the relational database.

Dr. E.F.Codd proposed the relational model for database systems.
It is the basis for RDBMS,
RDBMS consists of
Collection of objects or relations(tables),
set of operators to act on the relations, and
data integrity for accuracy and consistency

DBMS:
NDBMS->Network Database Management system
HDBMS->Hierarchical Dabatabase Management system
RDBMS->Relational Database Management system
ORDBMS=rdbms+odbms ->Object Relational Database Management system.

TABLE:IT IS A COLLECTION OF ROWS AND COLUMNS.
row, column (key column, non-key column), foreign key column,
cell/field (intersection of a column and a row),
null(unavailable, unassigned, unknown, inapplicable),
null is not same as a zero or a blank space
Columns of any datatype can contain nulls.
metadata - data about data.
data dictionary(SYSTEM TABLE)

Database schema: Collection of Objects

Database user: Account in database

In oracle schema and user share same name
One user is associated with one schema only.

SQL - STRUCTURE QUERY LANGUAGE
SEQUEL - STRUCTURE ENGLISH QUERY LANGUAGE

ANSI & ISO HAS APPROVED THIS SQL LANGUAGE AS A STANDARD LANGUAGE FOR ALL THE
RDBMS SOFTWARES.

ANSI - AMERICAN NATIONAL STANDARD INSTITUTE.
ISO - INTERNATIONAL STANDARD ORGANIZATION.

SQL: Structured Query Language
==============================
Can be pronounced as SEQUEL(Structure English Query Language)
Sub Languages in SQL
1) Data Definition Language (DDL)
2) Data Manipulation Language (DML)
3) Transaction Control Language (TCL)
4) Data Control Language (DCL)

DDL (DATA DEFINITION LANGUAGE):
CREATE, ALTER, DROP, TRUNCATE, RENAME, COMMENT

DML (DATA MANIPULATION LANGUAGE):
INSERT, UPDATE, DELETE, SELECT, MERGE

TCL (TRANSACTION CONTROL LANGUAGE):
COMMIT, ROLLBACK, SAVEPOINT

DCL (DATA CONTROL LANGUAGE):
GRANT, REVOKE

SQL Command Line (SQL*Plus)
iSQLPlus (discontinued after Oracle 10g)
SQL Developer (introduced with Oracle 11g)

TOAD - GUI(THIRD PARTY TOOL)

No comments:

Post a Comment