SlideShare a Scribd company logo
1 of 79
CLASS 12
COMPUTER SCIENCE
Syllabus (2020-21)
Unit I: Computational Thinking and
Programming- 2
● Revision of the basics of Python covered in Class XI.
● Functions: scope, parameter passing, mutable/immutable properties of
data objects, passing strings, lists, tuples, dictionaries to functions, default
parameters, positional parameters, return values, functions using libraries:
mathematical and string functions.
● File handling: Need for a data file, Types of file: Text files, Binary files and
CSV (Comma separated values) files.
Text File: Basic operations on a text file: Open (filename – absolute or
relative path, mode) / Close a text file, Reading and Manipulation of
data from a text file, Appending data into a text file, standard input /
output and error streams, relative and absolute paths.
● Binary File: Basic operations on a binary file: Open (filename –
absolute or relative path, mode) / Close a binary file, Pickle Module –
methods load and dump; Read, Write/Create, Search, Append and
Update operations in a binary file.
CSV File: Import csv module, functions – Open / Close a csv file, Read
from a csv file and Write into a csv file using csv.reader ( ) and
csv.writerow( ).
• Using Python libraries: create and import
Python libraries.
• Data-structures: Lists as covered in Class XI, Stacks
– Push, Pop using a list, Queues – Insert, Delete using
a list.
Unit III: Database Management
Database Concepts: Introduction to database concepts and its need.
Relational data model: Concept of domain, relation, tuple, attribute, degree,
cardinality, key, primary key, candidate key, alternate key and foreign key;
Structured Query Language:
General Concepts: Advantages of using SQL, Data Definition Language and
Data Manipulation Language;
Data Types: number / decimal, character / varchar / varchar2, date;
SQL commands: CREATE TABLE, DROP TABLE, ALTER TABLE, UPDATE
....SET...., INSERT, DELETE; SELECT, DISTINCT, FROM, WHERE, IN,
BETWEEN, LIKE, NULL / IS NULL, ORDER BY,GROUP BY, HAVING;
SQL functions: SUM ( ), AVG ( ), COUNT ( ), MAX ( ) and MIN ( );
Joins: equi-join and natural join
- Connecting SQL with Python
- Creating Database connectivity Applications
- Performing Insert, Update, Delete queries
- Display data by using
fetchone(),fetchall(),rowcount
Interface of Python with an SQL database
● Evolution of Networking: ARPANET, Internet, Interspace Different ways of sending data across
the network with reference to switching techniques (Circuit and Packet switching).
● Data Communication terminologies: Concept of Channel, Bandwidth (Hz, KHz, MHz) and Data
transfer rate (bps, Kbps, Mbps, Gbps, Tbps).
● Transmission media: Twisted pair cable, coaxial cable, optical fiber, infrared, radio link,
microwave link and satellite link.
● Network devices: Modem, RJ45 connector, Ethernet Card, Router, Switch, Gateway, WiFi card.
● Network Topologies and types: Bus, Star, Tree, PAN, LAN, WAN, MAN.
● Network Protocol: TCP/IP, File Transfer Protocol (FTP), PPP, HTTP, SMTP, POP3, Remote Login
(Telnet) and Internet, Wireless / Mobile Communication protocol such as GSM, GPRS and WLL.
● Mobile Telecommunication Technologies: 1G, 2G, 3G, 4G and 5G; Mobile processors; Electronic
mail protocols such as SMTP, POP3, Protocols for Chat and Video Conferencing: VoIP, Wireless
technologies such as Wi-Fi and WiMax Network Security Concepts: Threats and prevention from
Viruses, Worms, Trojan horse, Spams Use of Cookies, Protection using Firewall, https; India IT Act,
Cyber Law, Cyber Crimes, IPR issues, hacking.
● Introduction To Web services: WWW, Hyper Text Markup Language (HTML), Extensible Markup
Language (XML); Hyper Text Transfer Protocol (HTTP); Domain Names; URL; Website, Web browser,
Web 8 Servers; Web Hosting.
Unit II: Computer Network
https://dev.mysql.com/downloads/mysql/
Introduction to Database
https://www.youtube.com/watch?v=FR4QIeZaPeM&t=128s
Data, Relational Model
https://www.youtube.com/watch?v=W
mGgxTpGs_8
https://www.youtube.com/watch?v=w1E1
VXSSKSA
Relational Model – related terms
? RDBMS - Relation – table-OBJECT
? Domain – all values in a column – 1
? Tuple – each row - 2 -RECORD
? Attribute – each column - 3
? Degree (Attribute count) -5, Cardinality (Tuple count) -6
1
2
3
Written Work
Terms
? What are the advantages of database systems?
ANS SECURITY, PRIVACY(requires password),REDUCING
REDUNDANCY(not required to write students name multiple times for
different categories),AVOIDING INCONSISTENCY,DATA
INTEGRITY(database has a universal standard form
everywhere)SPEED(easy to check things fast)
? Give examples for : relation, domain, tuple, RDBMS, Domain, Attribute,
Degree, Cardinality, using a table.
Keys
? Primary : column/s used for unique
identification of each tuple
? Candidate: All attributes or combinations
which can serve as Primary key
? Alternate: Any candidate key which is not
chosen to be a Primary Key
? Foreign Key : A Primary key derived
from a different table, with values
Identify all the above keys in table:
Referential Integrity
? Rules to protect relation among records of tables,
during removal or modification.
? Conditions to be met:
? Parent table: Primary Key/ Unique
? Foreign key: same datatype as primary key
? Same database for both tables
Referential Integrity - Don’ts
? New values not allowed in foreign key, null allowed
?Cannot delete a record from parent table if value
exists in foreign key
delete from parent_table where Pri_key = v1;
delete from parent_table where Pri_key = v2;
? Cannot edit primary key, if it has matching records in
child table.
update parent_table set Pri_key = v4 where Pri_key = v1;
update parent_table set Pri_key = v4 where Pri_key = v3;
For_Key Col
1
Col
2
Existing
New
Pri_Key Col 1 Col 2
v1
v2
For_Ke
y
Col 1 Col 2
v1
v3
MySql , SQL
MySQL
A software/ RDBMS that uses SQL
Open Source
SQL – Structured Query Language
Language to use a database
Variance in commands across platforms
Test…
FEATURES - MYSQL
DDL (Data Definition Language) – It allows you to
perform various operations on the database such as
CREATE, ALTER and DROP objects.
DML (Data Manipulation Language) – It allows you to
access and manipulate data. It helps you to insert,
update, delete and retrieve data from the database.
DCL (Data Control Language) – It allows you to control
access to the database. Example – Grant or Revoke
access permissions.
TCL (Transaction Control Language) – It allows you to
deal with the transaction of the database. Example –
Commit, Rollback, Savepoint, Set Transaction.
QUESTIONS
? Identify the category to perform the following tasks:
? A) change a column’s width
? B) change a column’s data type
? C) add a new column
? D) remove a table
? E) remove only data from a table , but retain the column headers,
structure
? F) replace data with new data
? G) add a new row of data / tuple
? H) remove the user accessibility to a set of tables.
SQL COMMANDS
MySql client
• Click open MySql command line client
• Enter password
• Type the following command to start working:
• Use test;
• Test is the name of the database
• You can also make a database:
• Create database new;
Formats
• Use semicolon at the end of each statement.
• SQL is NOT case sensitive but is DATA SENSITIVE
• Use : https://www.db-fiddle.com/ or
http://sqlfiddle.com/, temporarily
Data types
? Varchar versus char
? First_name: varchar(10) , Last_name : char(10)
Bytes for First_name Bytes for last_name
6 10 (King_ _ _ _ _ _)
5 10(Kochhar_ _ _)
3 10(De Haan_ _ _)
Other data types
? integer or int
? float
? date – format for storing date values: yyyy-mm-dd
? You can use built in functions to convert a string to date
form
Command, clause
• SQL commands are the instructions used to
communicate with a database to perform tasks,
functions, and queries with data.
• Clauses are subsets of commands that modify the
command.
Commands, clauses
1. Create table (with constraints)
2. desc
3. Insert into….values, insert into t1(select * from t2)
4. Select – simple
5. Order by – single column, multiple cols
6. Where : relational operators, in , between, like (%, _), is, is
not, logical operators
7. Update…set…where
8. Delete from…where
9. Alter table…add…modify….change…..drop column
10. Drop table
1. Create table
Command used to make a table structure with column headers
• CREATE TABLE [IF NOT EXISTS] table_name (
column1 datatype [constraint / key],
column2 datatype,
column3 datatype,
last column,
table level constraint 1,
table level constraint 2,
…
);
Example: create table emp(
empcode int(5) PRIMARY KEY, name varchar(15), doj date, sal
float(6,2) );
Table level:
create table emp(
empcode int(5) , name varchar(15), doj date, sal float(6,2),
primary key(empcode));
2. desc
Command that displays structure of the table , with
column description, basic constraints, null options, default
values
• Desc table;
• Or
• Describe table;
Example:
Desc emp;
3. Insert into…values()
• Used to add data into a table , using values clause
• insert into t1(select * from t2)
• Insert into table_name (col1,col2,col3..)
• Values(v1,v2,v3…);
• Example:
Insert into emp( empcode , name, doj , sal)
Values( 101, 'abc', '2021-02-01', 30000);
Date value is entered in the format: ‘yyyy-mm-dd’
Strings are entered in single quotes only - Do not
use double quotes
Blank value is indicated by typing NULL
TEST
Theory, create, desc, insert commands
4. Select – simple form
• Displays values of the columns specified in the statement.
Result table has the column names specified in the query,
using from clause.
• Select col1, col2, col3… from table;
• Or
• Select * from table; (to display all columns)
• Example:
• Select empcode , name from emp;
• Select * from emp;
5. Order by – single column,
multiple cols
• This clause works with select command to display values
in ascending / descending order of the chosen column.
• Default order: ascending
• Select col1, col2…from table order by col2 [desc];
• Example:
• Select name,sal order by doj;
• Table is ordered in increasing order of doj, from where
name and sal values are displayed.
• Multiple columns:
• Select name,sal order by name,doj;
• Arranges all names in ascending order, followed by
dates, for repeated values.
Where clause
Applying conditions
Where : relational operators
• All operators same as in python , except ==
• Use = for equality comparison in sql
• All operators work on all three data types: numeric,
varchar, date
• Example:
• Select name from emp where sal>25000;
• Select name from emp where name>’Alex’;
• Select name from emp where doj> ‘2020-01-01’;
All operators work
on all data types
Where: Logical operators
• And, or , not
• Same as in python
• Work on all data types
• Select empcode from emp where not( sal>20000 and
sal<30000);
• Select name from emp where empcode=101 or
name=‘Richa’;
Where: in , between
• In operator can be used to match against multiple values
for the same column.
• Example:
• Select name from emp where empcode in(101,201);
• Between works to select values in a range, both values
inclusive; Example:
• Select name from emp where sal between 20000 and
50000;
Where : like (%, _)
• Used for pattern matching: starts with letter ‘A’, in the
month of jan, etc
• % and _ are wild card characters. They are used to
substitute unknown characters.
• % represents many characters
• _ represents one
• Example:
• Select name from emp where name like ‘A%’;
• Select doj from emp where doj like ‘%jan%’;
Where: is, is not
• Is operator works with null value only
• It can be combined with not operator
• Example :
• Select name from emp where doj is null;
• Select name from emp where sal is not null;
SQL COMMANDS
Editing and deleting data, table
INDEX
Update…set…where
Delete from…where
Alter table…add…modify….change…..drop column
Drop table
46
Update…set
The command is used to replace/edit data .
Update <table> set <col> = <value> [where clause]
The command changes all values of a column, if where clause is not used.
Example:
Update emp set empcode=201;
-changes all values under the column empcode to 201
Update emp set empcode=201 where name= ‘Yash’;
-changes value of all tuples containing the name yash
47
Delete from…where
• The command removes tuple/s from a table
• If used without where clause, removes all tuples.
• Delete from <table> [where clause]
• Example
• Delete from emp where empcode=101;
• Removes all rows with the given code
• Delete from emp;
• Removes all rows
48
9/3/20XX
PRESENTATION TITLE
EDITING TABLE
STRUCTURE
Adding foreign key
(using create table)
• Method 1 – column level
• Create table table_name (col1 definition
…… common_column datatype references parent_table (common_column) );
• Method 2 – Table level
• Create table table_name (col1 definition,……last_col definition,
foreign key common_column references parent_table (common_column)
);
References:
https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html
https://dev.mysql.com/doc/refman/8.0/en/ansi-diff-foreign-keys.html
Drop table
Removes a table along with all content/data
• Drop table <tablename>
• Drop table emp;
To remove particular column:
alter table emp
drop ename;
Alter table
Clauses
• Add
• Modify
• Change
• Drop column
Description
• Add a new column.
• Change column type or width.
• Change column name or position
• Remove a column
• Alter table <table name>add <column definition>;
• Alter table <table name> modify <column definition>;
• Alter table <table name> change [COLUMN] old_col_name new_col_name
column_definition [FIRST | AFTER col_name]
• Alter table <table name> DROP [COLUMN] col_name
Examples
• Alter table emp add
( email varchar(15) );
Alter table emp add email
varchar(20) FIRST;
Alter table emp add email
varchar(20) AFTER sal;
• Alter table emp modify
( name varchar(25)) ;
• Alter table emp change
name empname varchar(15) FIRST ;
• Alter table emp change empcode ecode
int after sal;
• Alter table emp DROP sal;
Adding foreign key
(using alter table)
• ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (col_name, ...) REFERENCES tbl_name (col_name,...) [ON
DELETE reference_option] [ON UPDATE reference_option]
• Example:
• ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
• Or
• ALTER TABLE Orders
ADD CONSTRAINT FK_PersonOrder
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
ALTER TABLE table_name ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1,
column2...);
alter table student
add constraint primary key(rollno);
alter table student
-> add constraint check(dob>'2000-09-09');
alter table emp
add constraint c1 check (deptno>5);
alter table student
-> drop primary key;
alter table emp
drop primary key MyPrimaryKey;
alter table emp
drop constraint c1;
alter table student
alter marks set default 30;
alter table student
alter marks drop default;
alter table club
alter clubname drop default;
alter table club
modify clubname varchar(30) not null;
alter table club
modify clubname varchar(30);
56
Table constraints
create table emp
(empno int(3)not null,
ename varchar(20),
doj date,
dob date,
deptno int(3),
primary key (empno,dob));
Table constraint - Foreign key
create table emp
-> (empno int(3) not null primary key,
-> ename varchar(20) not null,
-> doj date,
-> sal int(5),
-> deptno int(3),
-> foreign key (deptno) references dept(deptno));
57
SQL COMMANDS
joins, aggregate functions,
group by..having
Joins
✔Cartesian Product – no condition, each value of T1with each value
of T2
✔Equi join – where cluase with = operator
✔Natural Join – same as equi, but common column chosen by DBMS
https://www.youtube.com/watch?v=bLL5NbBEg2I
https://dataschool.com/how-to-teach-people-sql/inner-join-
animated/
Cartesian Product
Equi Join
Natural Join
Aggregate/ group functions
1. SUM ( ) – only numeric
columns
2. AVG ( ) - only numeric
columns
3. COUNT ( ) – any type
4. MAX ( ) – any type
5. MIN ( ) – any type
6. Distinct or all can be used
7. * can be used only with count
– indicates to include null.
Avg returns a decimal /
float value
Null is
ignored
Group by…
having
Having..
Having versus where
Position - All clauses
1. From (single /
multiple tables)
2. Where
3. Group by
4. Having
5. Order by
? Without /with join
? Select required rows
? Merge rows, create
groups
? Select groups using
group functions
? Arrange the result of
the above
Exercise
Practice Questions
Ans here
Ans here
Ans here
Ans here
CS12 Syllabus
CS12 Syllabus
CS12 Syllabus

More Related Content

Similar to CS12 Syllabus

MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...
MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...
MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...SequelGate
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldevllangit
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developersllangit
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developersllangit
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The EnterpriseDaniel Egan
 
Sparkling Water Meetup 4.15.15
Sparkling Water Meetup 4.15.15Sparkling Water Meetup 4.15.15
Sparkling Water Meetup 4.15.15Sri Ambati
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurSiddharth Mathur
 
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)Michael Rys
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And XmlDavid Truxall
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...TAISEEREISA
 

Similar to CS12 Syllabus (20)

MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...
MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...
MSBI with SQL Server T-SQL | Microsoft BI With Server T-SQL | Realtime Traini...
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldev
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developers
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Big data concepts
Big data conceptsBig data concepts
Big data concepts
 
Sparkling Water Meetup 4.15.15
Sparkling Water Meetup 4.15.15Sparkling Water Meetup 4.15.15
Sparkling Water Meetup 4.15.15
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathur
 
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
 
MYSQL-Database
MYSQL-DatabaseMYSQL-Database
MYSQL-Database
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
 
PT- Oracle session01
PT- Oracle session01 PT- Oracle session01
PT- Oracle session01
 
Module02
Module02Module02
Module02
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
 
Sql
SqlSql
Sql
 

Recently uploaded

Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment BookingCall Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Bookingnoor ahmed
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...Neha Kaur
 
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Riya Pathan
 
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Riya Pathan
 
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...ranjana rawat
 
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...anamikaraghav4
 
👙 Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service
👙  Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service👙  Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service
👙 Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Serviceanamikaraghav4
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaRiya Pathan
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130Suhani Kapoor
 
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...anamikaraghav4
 
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls
 
fmovies-Movies hold a special place in the hearts
fmovies-Movies hold a special place in the heartsfmovies-Movies hold a special place in the hearts
fmovies-Movies hold a special place in the heartsa18205752
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Riya Pathan
 
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Apsara Of India
 
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...anamikaraghav4
 
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsCall Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsApsara Of India
 
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...noor ahmed
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...aamir
 

Recently uploaded (20)

Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Najafgarh Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment BookingCall Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
 
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
 
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Bagbazar 👉 8250192130 ❣️💯 Available With Room 24×7
 
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
 
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
 
👙 Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service
👙  Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service👙  Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service
👙 Kolkata Call Girls Shyam Bazar 💫💫7001035870 Model escorts Service
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
 
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
 
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
 
fmovies-Movies hold a special place in the hearts
fmovies-Movies hold a special place in the heartsfmovies-Movies hold a special place in the hearts
fmovies-Movies hold a special place in the hearts
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
 
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
 
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
 
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal EscortsCall Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
Call Girls In Karnal O8860008073 Sector 6 7 8 9 Karnal Escorts
 
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
 

CS12 Syllabus

  • 3. Unit I: Computational Thinking and Programming- 2 ● Revision of the basics of Python covered in Class XI. ● Functions: scope, parameter passing, mutable/immutable properties of data objects, passing strings, lists, tuples, dictionaries to functions, default parameters, positional parameters, return values, functions using libraries: mathematical and string functions. ● File handling: Need for a data file, Types of file: Text files, Binary files and CSV (Comma separated values) files.
  • 4. Text File: Basic operations on a text file: Open (filename – absolute or relative path, mode) / Close a text file, Reading and Manipulation of data from a text file, Appending data into a text file, standard input / output and error streams, relative and absolute paths. ● Binary File: Basic operations on a binary file: Open (filename – absolute or relative path, mode) / Close a binary file, Pickle Module – methods load and dump; Read, Write/Create, Search, Append and Update operations in a binary file. CSV File: Import csv module, functions – Open / Close a csv file, Read from a csv file and Write into a csv file using csv.reader ( ) and csv.writerow( ).
  • 5. • Using Python libraries: create and import Python libraries. • Data-structures: Lists as covered in Class XI, Stacks – Push, Pop using a list, Queues – Insert, Delete using a list.
  • 6. Unit III: Database Management Database Concepts: Introduction to database concepts and its need. Relational data model: Concept of domain, relation, tuple, attribute, degree, cardinality, key, primary key, candidate key, alternate key and foreign key; Structured Query Language: General Concepts: Advantages of using SQL, Data Definition Language and Data Manipulation Language; Data Types: number / decimal, character / varchar / varchar2, date; SQL commands: CREATE TABLE, DROP TABLE, ALTER TABLE, UPDATE ....SET...., INSERT, DELETE; SELECT, DISTINCT, FROM, WHERE, IN, BETWEEN, LIKE, NULL / IS NULL, ORDER BY,GROUP BY, HAVING; SQL functions: SUM ( ), AVG ( ), COUNT ( ), MAX ( ) and MIN ( ); Joins: equi-join and natural join
  • 7. - Connecting SQL with Python - Creating Database connectivity Applications - Performing Insert, Update, Delete queries - Display data by using fetchone(),fetchall(),rowcount Interface of Python with an SQL database
  • 8. ● Evolution of Networking: ARPANET, Internet, Interspace Different ways of sending data across the network with reference to switching techniques (Circuit and Packet switching). ● Data Communication terminologies: Concept of Channel, Bandwidth (Hz, KHz, MHz) and Data transfer rate (bps, Kbps, Mbps, Gbps, Tbps). ● Transmission media: Twisted pair cable, coaxial cable, optical fiber, infrared, radio link, microwave link and satellite link. ● Network devices: Modem, RJ45 connector, Ethernet Card, Router, Switch, Gateway, WiFi card. ● Network Topologies and types: Bus, Star, Tree, PAN, LAN, WAN, MAN. ● Network Protocol: TCP/IP, File Transfer Protocol (FTP), PPP, HTTP, SMTP, POP3, Remote Login (Telnet) and Internet, Wireless / Mobile Communication protocol such as GSM, GPRS and WLL. ● Mobile Telecommunication Technologies: 1G, 2G, 3G, 4G and 5G; Mobile processors; Electronic mail protocols such as SMTP, POP3, Protocols for Chat and Video Conferencing: VoIP, Wireless technologies such as Wi-Fi and WiMax Network Security Concepts: Threats and prevention from Viruses, Worms, Trojan horse, Spams Use of Cookies, Protection using Firewall, https; India IT Act, Cyber Law, Cyber Crimes, IPR issues, hacking. ● Introduction To Web services: WWW, Hyper Text Markup Language (HTML), Extensible Markup Language (XML); Hyper Text Transfer Protocol (HTTP); Domain Names; URL; Website, Web browser, Web 8 Servers; Web Hosting. Unit II: Computer Network
  • 12. Relational Model – related terms ? RDBMS - Relation – table-OBJECT ? Domain – all values in a column – 1 ? Tuple – each row - 2 -RECORD ? Attribute – each column - 3 ? Degree (Attribute count) -5, Cardinality (Tuple count) -6 1 2 3
  • 14. Terms ? What are the advantages of database systems? ANS SECURITY, PRIVACY(requires password),REDUCING REDUNDANCY(not required to write students name multiple times for different categories),AVOIDING INCONSISTENCY,DATA INTEGRITY(database has a universal standard form everywhere)SPEED(easy to check things fast) ? Give examples for : relation, domain, tuple, RDBMS, Domain, Attribute, Degree, Cardinality, using a table.
  • 15. Keys ? Primary : column/s used for unique identification of each tuple ? Candidate: All attributes or combinations which can serve as Primary key ? Alternate: Any candidate key which is not chosen to be a Primary Key ? Foreign Key : A Primary key derived from a different table, with values
  • 16.
  • 17. Identify all the above keys in table:
  • 18. Referential Integrity ? Rules to protect relation among records of tables, during removal or modification. ? Conditions to be met: ? Parent table: Primary Key/ Unique ? Foreign key: same datatype as primary key ? Same database for both tables
  • 19. Referential Integrity - Don’ts ? New values not allowed in foreign key, null allowed ?Cannot delete a record from parent table if value exists in foreign key delete from parent_table where Pri_key = v1; delete from parent_table where Pri_key = v2; ? Cannot edit primary key, if it has matching records in child table. update parent_table set Pri_key = v4 where Pri_key = v1; update parent_table set Pri_key = v4 where Pri_key = v3; For_Key Col 1 Col 2 Existing New Pri_Key Col 1 Col 2 v1 v2 For_Ke y Col 1 Col 2 v1 v3
  • 20. MySql , SQL MySQL A software/ RDBMS that uses SQL Open Source SQL – Structured Query Language Language to use a database Variance in commands across platforms
  • 23.
  • 24. DDL (Data Definition Language) – It allows you to perform various operations on the database such as CREATE, ALTER and DROP objects. DML (Data Manipulation Language) – It allows you to access and manipulate data. It helps you to insert, update, delete and retrieve data from the database. DCL (Data Control Language) – It allows you to control access to the database. Example – Grant or Revoke access permissions. TCL (Transaction Control Language) – It allows you to deal with the transaction of the database. Example – Commit, Rollback, Savepoint, Set Transaction.
  • 25. QUESTIONS ? Identify the category to perform the following tasks: ? A) change a column’s width ? B) change a column’s data type ? C) add a new column ? D) remove a table ? E) remove only data from a table , but retain the column headers, structure ? F) replace data with new data ? G) add a new row of data / tuple ? H) remove the user accessibility to a set of tables.
  • 27. MySql client • Click open MySql command line client • Enter password • Type the following command to start working: • Use test; • Test is the name of the database • You can also make a database: • Create database new;
  • 28. Formats • Use semicolon at the end of each statement. • SQL is NOT case sensitive but is DATA SENSITIVE • Use : https://www.db-fiddle.com/ or http://sqlfiddle.com/, temporarily
  • 29. Data types ? Varchar versus char ? First_name: varchar(10) , Last_name : char(10) Bytes for First_name Bytes for last_name 6 10 (King_ _ _ _ _ _) 5 10(Kochhar_ _ _) 3 10(De Haan_ _ _)
  • 30. Other data types ? integer or int ? float ? date – format for storing date values: yyyy-mm-dd ? You can use built in functions to convert a string to date form
  • 31. Command, clause • SQL commands are the instructions used to communicate with a database to perform tasks, functions, and queries with data. • Clauses are subsets of commands that modify the command.
  • 32. Commands, clauses 1. Create table (with constraints) 2. desc 3. Insert into….values, insert into t1(select * from t2) 4. Select – simple 5. Order by – single column, multiple cols 6. Where : relational operators, in , between, like (%, _), is, is not, logical operators 7. Update…set…where 8. Delete from…where 9. Alter table…add…modify….change…..drop column 10. Drop table
  • 33. 1. Create table Command used to make a table structure with column headers • CREATE TABLE [IF NOT EXISTS] table_name ( column1 datatype [constraint / key], column2 datatype, column3 datatype, last column, table level constraint 1, table level constraint 2, … ); Example: create table emp( empcode int(5) PRIMARY KEY, name varchar(15), doj date, sal float(6,2) ); Table level: create table emp( empcode int(5) , name varchar(15), doj date, sal float(6,2), primary key(empcode));
  • 34. 2. desc Command that displays structure of the table , with column description, basic constraints, null options, default values • Desc table; • Or • Describe table; Example: Desc emp;
  • 35. 3. Insert into…values() • Used to add data into a table , using values clause • insert into t1(select * from t2) • Insert into table_name (col1,col2,col3..) • Values(v1,v2,v3…); • Example: Insert into emp( empcode , name, doj , sal) Values( 101, 'abc', '2021-02-01', 30000); Date value is entered in the format: ‘yyyy-mm-dd’ Strings are entered in single quotes only - Do not use double quotes Blank value is indicated by typing NULL
  • 36. TEST Theory, create, desc, insert commands
  • 37. 4. Select – simple form • Displays values of the columns specified in the statement. Result table has the column names specified in the query, using from clause. • Select col1, col2, col3… from table; • Or • Select * from table; (to display all columns) • Example: • Select empcode , name from emp; • Select * from emp;
  • 38. 5. Order by – single column, multiple cols • This clause works with select command to display values in ascending / descending order of the chosen column. • Default order: ascending • Select col1, col2…from table order by col2 [desc]; • Example: • Select name,sal order by doj; • Table is ordered in increasing order of doj, from where name and sal values are displayed. • Multiple columns: • Select name,sal order by name,doj; • Arranges all names in ascending order, followed by dates, for repeated values.
  • 40. Where : relational operators • All operators same as in python , except == • Use = for equality comparison in sql • All operators work on all three data types: numeric, varchar, date • Example: • Select name from emp where sal>25000; • Select name from emp where name>’Alex’; • Select name from emp where doj> ‘2020-01-01’; All operators work on all data types
  • 41. Where: Logical operators • And, or , not • Same as in python • Work on all data types • Select empcode from emp where not( sal>20000 and sal<30000); • Select name from emp where empcode=101 or name=‘Richa’;
  • 42. Where: in , between • In operator can be used to match against multiple values for the same column. • Example: • Select name from emp where empcode in(101,201); • Between works to select values in a range, both values inclusive; Example: • Select name from emp where sal between 20000 and 50000;
  • 43. Where : like (%, _) • Used for pattern matching: starts with letter ‘A’, in the month of jan, etc • % and _ are wild card characters. They are used to substitute unknown characters. • % represents many characters • _ represents one • Example: • Select name from emp where name like ‘A%’; • Select doj from emp where doj like ‘%jan%’;
  • 44. Where: is, is not • Is operator works with null value only • It can be combined with not operator • Example : • Select name from emp where doj is null; • Select name from emp where sal is not null;
  • 45. SQL COMMANDS Editing and deleting data, table
  • 47. Update…set The command is used to replace/edit data . Update <table> set <col> = <value> [where clause] The command changes all values of a column, if where clause is not used. Example: Update emp set empcode=201; -changes all values under the column empcode to 201 Update emp set empcode=201 where name= ‘Yash’; -changes value of all tuples containing the name yash 47
  • 48. Delete from…where • The command removes tuple/s from a table • If used without where clause, removes all tuples. • Delete from <table> [where clause] • Example • Delete from emp where empcode=101; • Removes all rows with the given code • Delete from emp; • Removes all rows 48 9/3/20XX PRESENTATION TITLE
  • 50. Adding foreign key (using create table) • Method 1 – column level • Create table table_name (col1 definition …… common_column datatype references parent_table (common_column) ); • Method 2 – Table level • Create table table_name (col1 definition,……last_col definition, foreign key common_column references parent_table (common_column) ); References: https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html https://dev.mysql.com/doc/refman/8.0/en/ansi-diff-foreign-keys.html
  • 51. Drop table Removes a table along with all content/data • Drop table <tablename> • Drop table emp; To remove particular column: alter table emp drop ename;
  • 52. Alter table Clauses • Add • Modify • Change • Drop column Description • Add a new column. • Change column type or width. • Change column name or position • Remove a column • Alter table <table name>add <column definition>; • Alter table <table name> modify <column definition>; • Alter table <table name> change [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name] • Alter table <table name> DROP [COLUMN] col_name
  • 53. Examples • Alter table emp add ( email varchar(15) ); Alter table emp add email varchar(20) FIRST; Alter table emp add email varchar(20) AFTER sal; • Alter table emp modify ( name varchar(25)) ; • Alter table emp change name empname varchar(15) FIRST ; • Alter table emp change empcode ecode int after sal; • Alter table emp DROP sal;
  • 54. Adding foreign key (using alter table) • ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (col_name, ...) REFERENCES tbl_name (col_name,...) [ON DELETE reference_option] [ON UPDATE reference_option] • Example: • ALTER TABLE Orders ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID); • Or • ALTER TABLE Orders ADD CONSTRAINT FK_PersonOrder FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
  • 55. ALTER TABLE table_name ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...); alter table student add constraint primary key(rollno); alter table student -> add constraint check(dob>'2000-09-09'); alter table emp add constraint c1 check (deptno>5); alter table student -> drop primary key; alter table emp drop primary key MyPrimaryKey; alter table emp drop constraint c1;
  • 56. alter table student alter marks set default 30; alter table student alter marks drop default; alter table club alter clubname drop default; alter table club modify clubname varchar(30) not null; alter table club modify clubname varchar(30); 56
  • 57. Table constraints create table emp (empno int(3)not null, ename varchar(20), doj date, dob date, deptno int(3), primary key (empno,dob)); Table constraint - Foreign key create table emp -> (empno int(3) not null primary key, -> ename varchar(20) not null, -> doj date, -> sal int(5), -> deptno int(3), -> foreign key (deptno) references dept(deptno)); 57
  • 58. SQL COMMANDS joins, aggregate functions, group by..having
  • 59. Joins ✔Cartesian Product – no condition, each value of T1with each value of T2 ✔Equi join – where cluase with = operator ✔Natural Join – same as equi, but common column chosen by DBMS https://www.youtube.com/watch?v=bLL5NbBEg2I https://dataschool.com/how-to-teach-people-sql/inner-join- animated/
  • 63. Aggregate/ group functions 1. SUM ( ) – only numeric columns 2. AVG ( ) - only numeric columns 3. COUNT ( ) – any type 4. MAX ( ) – any type 5. MIN ( ) – any type 6. Distinct or all can be used 7. * can be used only with count – indicates to include null.
  • 64. Avg returns a decimal / float value Null is ignored
  • 65.
  • 68.
  • 69.
  • 71. Position - All clauses 1. From (single / multiple tables) 2. Where 3. Group by 4. Having 5. Order by ? Without /with join ? Select required rows ? Merge rows, create groups ? Select groups using group functions ? Arrange the result of the above