TN Online TestSamacheer Kalvi practice

Structured Query Language (SQL) - Study Notes

Share this chapter: Telegram

Chapter Summary

Structured Query Language (SQL) is the standard database programming language used to construct, query, manage, and modify relational database management systems (RDBMS). SQL serves as the primary tool to handle structural descriptions of schemas, perform record-level manipulations such as insertion, modification, and deletion, and coordinate transactions to ensure data consistency and accuracy.

Learning Objectives

Key Concepts and Definitions

Worked Methods

1. Table Creation with Column Constraints

Creating a structured table requires defining field names, their respective data types, sizes, and any appropriate constraints. For example, a student table with multiple constraints is created using the following method:

CREATE TABLE Student (Admno integer NOT NULL PRIMARY KEY, Name char(20) NOT NULL, Gender char(1), Age integer DEFAULT 17, Place char(10));

2. Filtering Data Using Select Clauses

Retrieving specific information requires combining the SELECT statement with conditional clauses such as WHERE, BETWEEN, and IN. For instance, selecting students from Chennai or Delhi whose age is between 18 and 19:

SELECT Admno, Name FROM Student WHERE Place IN ('Chennai', 'Delhi') AND Age BETWEEN 18 AND 19;

3. Data Aggregation and Grouping

Summary reports can be produced by utilizing the GROUP BY clause alongside aggregate functions like COUNT, MAX, MIN, SUM, or AVG. To filter grouped rows based on an aggregate condition, the HAVING clause is required:

SELECT Place, COUNT(*) FROM Student GROUP BY Place HAVING COUNT(*) > 1;

Common Exam Traps

Exam Tips

Solved MCQs → Practice test →

More for this chapter

Book Back Questions5 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Formula SheetAll key formulas

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python -Variables and Operators 6 Control Structures 7 Python functions 8 Strings and String manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and objects 11 Database Concepts 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart