Structured Query Language
Structured Query Language
Structured Query Language
Language
RDBMS
RDBMS stands
for Relational Database Management System.
RDBMS is the basis for SQL, and for all
modern database systems like MS SQL Server,
IBM DB2, Oracle, MySQL, and Microsoft
Access.
A Relational database management system
limit the type of data that can go into a table. This ensures the accuracy and
reliability of the data in the database.
Constraints can either be column level or table level. Column level constraints are
applied only to one column whereas, table level constraints are applied to the entire
table.
Following are some of the most commonly used constraints available in SQL −
NOT NULL Constraint − Ensures that a column cannot have a NULL value.
DEFAULT Constraint − Provides a default value for a column when none is specified.
UNIQUE Constraint − Ensures that all the values in a column are different.
PRIMARY Key − Uniquely identifies each row/record in a database table.
FOREIGN Key − Uniquely identifies a row/record in any another database table.
CHECK Constraint − The CHECK constraint ensures that all values in a column satisfy
certain conditions.
INDEX − Used to create and retrieve data from the database very quickly.
Some Concept
Data Integrity
The following categories of data integrity exist with each
RDBMS −
Entity Integrity − There are no duplicate rows in a table.
Domain Integrity − Enforces valid entries for a given
E.g. SELECT
DML(Data Manipulation Language) : The SQL
table_2 ON join_condition;
Views
Views are database objects which donot store
data physically. When we execute the SELECT
statement against the view, MySQL executes the
underlying query specified in the view’s
definition and returns the result set. For this
reason, sometimes, a view is referred to as a
virtual table.
Views can be created with CREATE View
command, can be updated with CREATE OR
REPLACE View command and can be deleted with
Drop View <View name> statement.
Stored Procedure
A procedure (often called a stored procedure) is a
subroutine like a subprogram in a regular computing
language, stored in database. A procedure has a name,
a parameter list, and SQL statement(s). Almost all
relational database system supports stored procedure.
Advantages:
Stored procedures are fast as they are compiled once.
Stored procedures are portable. When you write your
IN parameters
OUT parameter
INOUT parameter
DISTINCT and IN
The SELECT DISTINCT command returns only
distinct (different) values in the result set.
E.g.
SELECT DISTINCT Prod_id FROM TransMaster;
changed
The primary key must be given a value when a
new record is inserted.
2NF (Second Normal Form) Rules
Rule 1- Be in 1NF
Rule 2- Single Column Primary Key
It is clear that we can't move forward to make
Another table
Third normal Form
Rule 1- Be in 2NF
Rule 2- Has no transitive functional
dependencies
Third Normal Form
Third Normal Form
Types of DBMS
Database Management System (DBMS) is a software
for storing and retrieving users' data while
considering appropriate security measures.
Network database.
Relational database.
Object-Oriented database.
DBMS
Hierarchical DBMS
In a Hierarchical database, model data is organized in a tree-like
structure. Data is Stored Hierarchically (top down or bottom up) format.
Data is represented using a parent-child relationship. In Hierarchical
DBMS parent may have many children, but children have only one
parent.
Network Model
Relational DBMS is the most widely used DBMS model because it is one
of the easiest. This model is based on normalizing data in the rows and
columns of the tables. Relational model stored in fixed structures and
manipulated using SQL.
DBMS
Object-Oriented Model