You are on page 1of 3

CLASS:XII

CHAPTER 5 : MY SQL – SQL REVISION TOUR

Referential Integrity : A referential integrity is a system of rules that a DBMS uses to


ensure that relationship between records in related tables are valid, and that users don’t
accidentally delete or change related data.

My SQL Database System : My SQL operates using client / server architecture in


which the server runs on the machine containing the databases and clients connect to
the server over a network.

The Server ( My SQL Server ) : listens for client requests coming in over the network
and accesses database contents according to those requests and provides that to the
clients.

Clients : are programs that connects to the database server and issue queries in a pre
specified format. MySQL is compatible with the standards based SQL.

MySQL and SQL : In order to access data within the MySQL database, all programs
and users must use Structured Query Language(SQL). SQL is the set of commands
that is recognized by all nearly all RDBMS.

The SQL is language that enables you to create and operate on relational databases,
which are sets of related information stored in tables.

Classification of SQL Statements:

SQL commands can be mainly divided into following categories :

1. Data Definition Language (DDL) Commands: Commands that allow you to perform
tasks related to data definition : Creating, altering and dropping tables

Eg. CREATE TABLE command

-1-
2. Data Manipulation Language (DML) commands: Commands that allows you to
perform data manipulation for example : retrieval, insertion, deletion and modification of
data stored in a database.

Eg. SELECT, DELETE, UPDATE command

Difference between CHAR & VARCHAR() data types:

The difference between CHAR and VARCHAR is that of fixed length and variable
length. The CHAR data types specifies a fixed length character string. When a column
is given data type as CHAR(n), then SQL ensures that all values stored in that column
have this length i.e. n bytes. If a value is shorter than this length n then blanks are
added, but the size of the value remains n bytes.

VARCHAR on other hand specifies a variable length string. When a column is given
data type as VARCHAR(n), then the maximum size a value in this column can have is n
bytes. Each value that is stored in this column stores exactly as you specify it i.e. no
blanks are added.

Fixed length records:-

1.All the records in the file are of same size.


2. Leads to memory wastage.
3. Access of the records is easier and faster.

Variable length records:-

1.Different records in the file have different sizes.


2. Memory efficient.
3. Access of the records is slower. .
Accessing Database in MySQL:

Command to use Database:

USE < database name>

Eg. USE Test;

-2-
Test is the sample database provided by the SQL.

To view the databases stored on MySQL we can give the following command is:

Mysql > SHOW DATABASES;

Creating Tables in MySQL:

Tables are defined the CREATE TABLE command. When a table is created, its
columns are named, data types and sizes are supplied for each column. Each table
must have at least one column.

Eg. CREATE TABLE STUDENT ( RNo Integer Primary key, Name Varchar(20), Marks
integer);

You might also like