0% found this document useful (0 votes)
2 views

SQL

The document provides an overview of SQL and Database Management Systems (DBMS), including definitions of data types, DDL, DML, and DQL. It explains the structure of databases, the importance of data organization, and includes examples of SQL commands for creating tables, inserting values, and managing data. Additionally, it covers constraints and keys in database design, along with practical SQL operations such as adding and removing columns and tables.

Uploaded by

sandsoul395
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL

The document provides an overview of SQL and Database Management Systems (DBMS), including definitions of data types, DDL, DML, and DQL. It explains the structure of databases, the importance of data organization, and includes examples of SQL commands for creating tables, inserting values, and managing data. Additionally, it covers constraints and keys in database design, along with practical SQL operations such as adding and removing columns and tables.

Uploaded by

sandsoul395
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

YOUTH AF

BY - AYUSH PODDAR
SQL &
DATABASE
CLASS – 12
COMPUTER
SCIENCE
Contents
1) Introduction
2) Data Types
3) DDL
4) DML
5) DQL
6) Constraints

CONTENTS
Introduction - DBMS :
• Database Management System
Data • Software used to manage databases.
Collection of raw, unorganized facts and details • Acts as an interface between the database &
like text, observations, figures, symbols etc. end users
Measured in terms of bits and bytes. • Lets us Add, Remove, Update, Delete Data.
• Reduces Duplicacy, Saves Time, Secured,
Accessibility etc.
Information
• For eg. - MySql, Oracle ........etc.
Processed, Organized & Structured form of data.
Use Cases -
Database :
Banking, Schools, Hospitals, Colleges etc.
Collection of Inter related data.
E.g. : (Teacher-Student), (Doctor-Patient) DBMS over File System -
INTRODUCTION

Data is stored in such a way that is can be easily Accessibility


accessed, managed and updated. Redundancy (duplication)
Inconsistency
Data → Information → Database → DBMS Specific data sharing etc…
© Youth Af
© Youth Af

SQL - S_Name S_Age S_DOB


Chaman 69 2005/06/03
▪ Structured Query Language Kamla 55 2006/09/24
▪ Language used to interact with DBMS. Pushpa 23 2009/05/14
▪ Non Case Sensitive
▪ Predefined Syntax & Code For Table :- Columns | Datatype

Database → Tables → Raw Data


Data Type in SQL :
• Int : To store intergral values (4 bytes)
• Float : To store decimal values (4 bytes)
• Date : Date format ( YYYY / MM / DD )
• Char : Character of fixed length (1-255)
• Varchar : Variable length

Char Varchar
Fixed Length Variable Length
Memory Wastage No Memory Wastage
SQL

Char(20) Varchar(20)
S_Name S_Age S_DOB
Chaman 69 2005/06/03
Kamla 55 2006/09/24
Pushpa 23 2009/05/14

Q) Create a table named “YOUTHAF” using SQL ?

CREATE DATABASE BDMOS ;

CREATE TABLE YOUTHAF


(
DDL : Data Definition Language S_Name Varchar ,
DML : Data Manipulation Language S_Age Int ,
S_DOB Date
DQL : Data Query Language
);

S_Name S_Age S_DOB


SQL

© Youth Af
Q) Write a SQL code to insert values in YOUTHAF S_Name S_Age S_DOB
Chaman 69 2005/06/03
INSERT INTO YOUTHAF VALUES
( ‘ Chaman’ , 69 , ‘ 2005/06/03 ’ ) ; Kamla 55 2006/09/24
Pappu 2003/02/16
S_Name S_Age S_DOB
Chaman 69 2005/06/03
INSERT INTO YOUTHAF VALUES (S_Name, S_DOB)
( ‘ Pappu’ , ‘ 2003/02/16 ’ ) ;
INSERT INTO YOUTHAF VALUES
( ‘ Chaman’ , 69 , ‘ 2005/06/03 ’ ) , NOTE:
( ‘ Kamla’ , 55 , ‘ 2006/09/24 ’ ) ; Except numerical values everything is enclosed
in quotation marks
S_Name S_Age S_DOB
Chaman 69 2005/06/03
Kamla 55 2006/09/24
SQL

© Youth Af
Relation : Other name of table Q) Create a table “STUD” with CONSTRAINTS :-
Attribute : Columns or Fields
Column Datatype Size Constraints
Tuple : Rows or Records
SRollNo Int Primary Key
Degree : No. of rows
SAdmNo Int
Cardinality : No. of columns SName Varchar 30 NOT NULL
SMarks Int Greater than 40
KEYS -
DOB Date NOT NULL
Primary Key : Unique Identification (Non Empty) Gender Char 1
Candidate Key : Keys which can act as Primary Key City Varchar 20 Default : Delhi
Alternate Key : All Candidate Keys except Primary
CREATE TABLE STUD
(
SRollNo INTEGER PRIMARY KEY ,
SAdmNo INTEGER ,
SName VARCHAR (30) NOT NULL ,
SMarks INTEGER CHECK (Smarks>40) ,
DOB DATE NOT NULL ,
Gender CHAR (1) ,
City VARCHAR DEFAULT ‘Delhi’ ,
SQL

);
CREATE TABLE STUD Q) Write the SQL command to remove column “Age”.
(
SRollNo INTEGER PRIMARY KEY , ALTER TABLE STUD
SAdmNo INTEGER , (
SName VARCHAR (30) NOT NULL , DROP AGE ;
SMarks INTEGER CHECK (Smarks>40) , );
DOB DATE NOT NULL ,
ALTER TABLE STUD
Gender CHAR (1) ,
(
City VARCHAR ,
DROP COLUMN AGE ;
);
);
SRollNo SAdmNo SName Smarks DOB Gender City
SRollNo SAdmNo SName Smarks DOB Gender City

Q) Write the SQL command to add new column “Age”.


Q) Write the SQL command to delete table STUD.
ALTER TABLE STUD (
DROP TABLE STUD
ADD ( AGE INTEGER ) ;
);
Q) Write SQL command to delete DATABASE BDMOS.
SRollNo SAdmNo SName Smarks DOB Gender City Age
DROP DATABASE BDMOS
SQL
SQL

© Youth Af
THANK YOU

NOTES IN DESCRIPTION

You might also like