Informatics Practices · Class 11 Optional
Ch 7Introduction to Structured Query Language (SQL) — Class 11 Informatics Practices, concept-first.
A database becomes useful only when we can actually create it, fill it with data, and ask it questions. The previous chapter built the theory — what a Relational Database Management System (RDBMS) is and why we need one.
Key concepts
Hover a concept to preview it and jump to its most relevant Q&A.
Table Creation
Think of the last time you tried to find a specific contact in your phone. If all your contacts were just listed in one long, unbroken list — no groups, no alphabetical order, no search — you would have to scroll through…
Most relevant Q&A
- Create table STUDENT.Preview
- Write SQL statements to insert the remaining 4 rows of table 8.7 in table STUDENT.Preview
- Choose appropriate answer with respect to the following code snippet. CREATE TABLE student ( name CHAR(30), student_id INT, gender CHAR(1),…Free
- Suppose your school management has decided to conduct cricket matches between students of class XI and Class XII. Students of each class are…Preview
Chapter contents
The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.
Introduction
A database becomes useful only when we can actually create it, fill it with data, and ask it questions.
Structured Query Language (SQL)
The heart of this section is a contrast between two ways of reaching data. In an ordinary file system, there is no built-in way to ask for data — a programmer must write a full application program for…
Installing MySQL
Before any SQL can be written, the software that understands it must be on your machine. MySQL is an open source RDBMS, which means it can be downloaded freely — the official website for this is https…
+−Activities1 question
Data Types and Constraints in MySQL
This section sets up the two ideas that every table definition rests on: data types and constraints. Both follow directly from how a relational database is organised.
Data type of Attribute
2 QA data type indicates the type of data value that an attribute can have — and choosing it is more consequential than it looks, because the data type of an attribute decides which operations can be per…
Constraints
A data type says what kind of value a column may hold; a constraint goes further and restricts which values are acceptable.
+−Think & Reflect1 question
SQL for Data Definition
Everything in a database begins with structure: before a single row of data exists, someone must declare what tables the database contains and what each column of each table looks like.
CREATE Database
A database is a named container managed by the DBMS — tables can only exist inside one. So the first step in building any MySQL project is to create that container, and only after that can relations b…
CREATE Table
3 QCreating the database StudentAttendance gives an empty container; the real design work is defining relations (creating tables) inside it.
+−Activities1 question
+−Think & Reflect1 question
+−Worked Examples1 question
DESCRIBE Table
After a table has been created, you will often need to check exactly how it was defined — which columns it has, their data types, and which constraints apply to them.
ALTER Table
3 QA table's structure is rarely perfect on the first attempt. After creating a table you may realise that an attribute needs to be added or removed, that the data type of an existing attribute must chan…
+−Activities1 question
+−Think & Reflect1 question
DROP Statement
Sometimes a table in a database — or the database itself — needs to be removed altogether. The DROP statement does this: it removes a database or a table permanently from the system.
SQL for Data Manipulation
The CREATE statements of the previous section built the database StudentAttendance with its three relations — STUDENT, GUARDIAN and ATTENDANCE.
INSERTION of Records
3 QA newly created table is an empty frame — the INSERT INTO statement is what puts records into it. Its basic syntax supplies one value per attribute:
+−Activities1 question
+−Activities1 question
SQL for Data Query
Everything so far — creating the database, defining tables, storing and manipulating records — has been preparation for the operation databases really exist for: getting data back out.
SELECT Statement
Creating tables and filling them with records is only half the story — the real power of a database shows when you start asking it questions.
QUERYING using Database OFFICE
20 QEvery organisation keeps its data in databases organised as related tables. The running example here is a database named OFFICE, which holds several connected tables such as EMPLOYEE and DEPARTMENT.
+−Activities1 question
+−Activities1 question
+−Think & Reflect1 question
+−Think & Reflect1 question
+−Think & Reflect1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
+−Worked Examples1 question
Data Updation and Deletion
Data manipulation does not end with putting records into a table and reading them back. Real data changes constantly: an address is corrected, a phone number is replaced, a person leaves and their rec…
Data Updation
Stored data is rarely final. We may need to make changes in the value(s) of one or more columns of existing records — an address changes, a phone number is replaced, a spelling mistake in a name is di…
Data Deletion
Records do not stay in a table forever. When an entity leaves the picture — a student leaves the school, an employee resigns — its record has to go.
Summary
- A database is a collection of related tables; MySQL is a relational DBMS. A table is a collection of rows and columns, where each row is a record and the columns describe the features (attributes) o…
Exercises
+−Show 10 questionsHide questions10 questions
- Q1Match the following clauses with their respective functions. | Clause | Function | |---|---| | ALTER | Insert the values in a table | | UPDA…Free
- Q2Choose appropriate answer with respect to the following code snippet. CREATE TABLE student ( name CHAR(30), student_id INT, gender CHAR(1),…Free
- Q3Fill in the blanks: a) ____________ declares that an index in one table is related to that in another table. i) Primary Key ii) Foreign Key…Free
- Q4Consider the following MOVIE database and answer the SQL queries based on it. | MovieID | MovieName | Category | ReleaseDate | ProductionCos…Preview
- Q5Suppose your school management has decided to conduct cricket matches between students of class XI and Class XII. Students of each class are…Preview
- Q6Using the sports database containing two relations (TEAM, MATCH_DETAILS), answer the following relational algebra queries. a) Retrieve the M…Preview
- Q7Differentiate between the following commands: a) ALTER and UPDATE b) DELETE and DROPPreview
- Q8Create a database called STUDENT_PROJECT having the following tables. Choose appropriate data type and apply necessary constraints. Table: S…Preview
- Q9An organization ABC maintains a database EMP-DEPENDENT to record the following details about its employees and their dependents. EMPLOYEE(Aa…Preview
- Q10A shop called Wonderful Garments that sells school uniforms maintain a database SCHOOL_UNIFORM as shown below. It consisted of two relations…Preview