Class 11 Informatics Practices – Introduction to SQL Notes

NCERT Class 11 Informatics Practices Chapter 8 – Introduction to SQL.

 

1. What is a Database?

A database is an organized collection of related data stored in a structured way so that it can be easily accessed and managed.

Example

Roll NoNameClassMarks
101RahulXI85
102PriyaXI92

2. DBMS (Database Management System)

A DBMS is software that allows users to create, manage and manipulate databases.

Functions of DBMS

  • Data storage
  • Data retrieval
  • Data modification
  • Data security
  • Data sharing

Examples of DBMS

  • MySQL
  • Oracle
  • Microsoft SQL Server
  • PostgreSQL

3. RDBMS (Relational Database Management System)

An RDBMS stores data in the form of tables consisting of rows and columns.

  • Row → Record
  • Column → Field

Example Table

RollNoNameClass
101RahulXI
102RiyaXI

4. What is SQL?

SQL (Structured Query Language) is used to communicate with a database.

Using SQL we can:

  • Create databases
  • Create tables
  • Insert records
  • Retrieve records
  • Update records
  • Delete records

Example Query

SELECT * FROM student;

This query displays all records from the student table.

5. Characteristics of SQL

  • SQL is case insensitive
    ( SELECT
    select
    Select )
    All mean the same.
  • SQL Commands end with a semicolon
    SELECT * FROM student;
  • SQL Queries can be written in multiple lines

6. SQL Command Categories

1. DDL (Data Definition Language)

DDL commands define database structure.

CommandPurpose
CREATECreate database or table
ALTERModify table structure
DROPDelete table or database
DESCDisplay table structure

Example

CREATE DATABASE SchoolDB;

7. CREATE TABLE

CREATE TABLE student(
rollno INT,
name CHAR(20),
class CHAR(5),
marks INT
);

8. INSERT Command

Used to insert records into a table.

INSERT INTO student
VALUES(101,'Rahul','XI',85);

9. SELECT Command

Used to retrieve data from tables.

SELECT * FROM student;

To display only specific columns:

SELECT name FROM student;

10. UPDATE Command

Used to modify existing records.

UPDATE student
SET marks = 88
WHERE rollno = 101;

11. DELETE Command

Used to remove records from a table.

DELETE FROM student
WHERE rollno = 103;

12. SQL Clauses

WHERE Clause

SELECT * FROM student
WHERE marks > 80;

ORDER BY Clause

SELECT * FROM student
ORDER BY marks DESC;

DISTINCT Clause

SELECT DISTINCT name
FROM student;

LIKE Clause

SELECT * FROM student
WHERE name LIKE 'R%';

13. Logical Operators

  • AND
  • OR
  • NOT

Example

SELECT * FROM student
WHERE marks > 80 AND class = 'XI';

14. Important Database Terms

TermMeaning
TableCollection of rows and columns
FieldColumn in a table
RecordRow containing complete information
Primary KeyUnique identifier of a record

Important SQL Commands for Exams

CREATE DATABASE
CREATE TABLE
DESC
INSERT INTO
SELECT
UPDATE
DELETE
ALTER
DROP

 

 

Recommended Posts