SlideShare a Scribd company logo
THE UNIVERSITY OF
LARKANA
Assignment of DBMS
Database
A database is a collection of information that is organized so it can be easily accessed, managed, and updated. Think of it as a
digital storage system where you can keep data, such as names, numbers, or records, and quickly find or change them when
needed.
For example, a database might store all the contact details for people in a company or all the products in a store
SQL
SQL (Structured Query Language) is a programming language used to manage and manipulate databases, specifically relational
databases. It allows users to create, read, update, and delete data stored in tables. SQL is the standard language for interacting
with most relational database systems.
Key Functions of SQL:
• Create: Make databases and tables.
• Read: Retrieve data.
• Update: Modify existing data.
• Delete: Remove data.
database in my squel assignment for students.pdf
Types of SQL Commands:
1. Data Definition Language (DDL)
o CREATE: Creates new database objects (e.g., tables). o ALTER: Modifies existing database structures. o
DROP: Deletes database objects.
o TRUNCATE: Removes all records from a table but keeps the structure.
2. Data Manipulation Language (DML)
o SELECT: Retrieves data from the database. o INSERT: Adds new records into a table.
o UPDATE: Modifies existing records in a table. o DELETE: Removes records from a table.
3. Data Control Language (DCL)
o GRANT: Gives users access to the database. o REVOKE: Removes users' access rights.
4. Transaction Control Language (TCL)
o COMMIT: Saves all changes made in the transaction. o ROLLBACK: Reverts changes if something goes
wrong.
o SAVEPOINT: Sets a point within a transaction to which you can later roll back.
5. Data Query Language (DQL)
o SELECT: Used to query and fetch data from the database.
1. CREATE DATABASE
o Definition: Creates a new database called student_info.
2. USE DATABASE
o Definition: Selects the student_info database to work within it.
3. CREATE TABLE
o Definition: Creates a table named student with specified columns such as id, name, age, batch, etc.
4. INSERT INTO
o Definition: Inserts records into the student table.
5. SELECT
o Definition: Retrieves data from the student table. The asterisk (*) selects all columns, while specific
column names like city, name, and age select only those fields.
6. DISTINCT
o Definition: Retrieves unique values from the specified column, avoiding duplicates
7. WHERE
o Definition: Filters the results based on specified conditions
8. Arithmetic Operators in WHERE
o Definition: Uses arithmetic operations within the WHERE clause.
9. Comparison Operators in WHERE
o Definition: Compares values using operators like != (not equal) and >= (greater than or equal).
10. Logical Operators (AND)
o Definition: Retrieves rows that satisfy both conditions.
11. Logical Operators (OR)
o Definition: Retrieves rows that satisfy either of the conditions.
database in my squel assignment for students.pdf
Definition
12. BETWEEN
o : Selects rows where a column's value falls within a
specified range.
13. IN
o Definition: Checks if a value exists within a specified set of
values.
Definition
14. NOT IN
o : Selects rows where a value is not part of the specified set.
Definition
15. LIMIT
Definition: Limits the number of rows returned by the query.
16. ORDER BY
o : Sorts the result set by the specified column (ascending or
descending).
Definition
17. COUNT (Aggregate Function)
o Definition: Returns the number of rows that match a
specified condition.
18. MAX (Aggregate Function)
o Definition: Returns the maximum value of the specified
column.
19. MIN (Aggregate Function)
o Definition: Returns the minimum value of the specified
column.
20. AVG (Aggregate Function)
o Definition: Returns the average value of a numeric column.
21. SUM (Aggregate Function)
o Definition: Returns the total sum of a numeric column.
22. GROUP BY
o Definition: Groups rows with the same values into
summary rows.
23. HAVING
o Definition: Filters rows after the GROUP BY using aggregate
conditions.
24. UPDATE
o Definition: Updates existing records in a table.
25. DELETE
o Definition: Deletes records from the table based on the
condition.
26. ALTER TABLE
o Definition: Modifies the structure of an existing table
(adding, renaming, modifying, or removing columns).
database in my squel assignment for students.pdf
database in my squel assignment for students.pdf
27. TRUNCATE
o Definition: Removes all rows from a table without deleting
the table itself.
28. VIEW
o Definition: Creates a virtual table based on the result of a
SELECT query.
29. AS (Alias)
o Definition: Provides an alias to column names.
30. LIKE
o Definition: Retrieves rows where a column matches a
specified pattern.
Joins
Create Database
Creates a new database named joins.
Use Database
Selects the joins database for subsequent queries.
Create Table – std_table
Creates a std_table table with columns for student ID, name, and city.
Create Table – sub_table
Creates a sub_table table with columns for student ID and subject name.
Insert Data into std_table
Inserts student records into the std_table table. Insert
Data into sub_table
Inserts subject records into the sub_table table.
Select all from std_table
Retrieves all records from the std_table table.
Select all from sub_table
Retrieves all records from the sub_table table.
Inner Join std_table and sub_table
Returns matching records from both student and sub where std_id is the same
in both tables.
Left Join std_table and sub_table
Returns all records from the std_table table and matching records from
sub_table (if any).
Right Join std_table and sub_table
Returns all records from the sub_table table and matching records from
std_table (if any)
Cross Join std_table and sub_table
Returns the Cartesian product of the std_table and sub_table tables (all
combinations).
ER DIAGRAM
Create Database
Definition: This query creates a new database named university_info.
Select Database
Definition: This query selects the university_info database for use.
Create Faculty Table
Definition: Creates the Faculty table with columns fac_id and
faculty_name.
Create School Table
Definition: Creates the School table linked to the Faculty table via fac_id.
Create Program Table
Definition: Creates the Program table linked to the School table via
scho_id.
Create Courses Table
Definition: Creates the Courses table linked to the Program table via
pro_id.
Create Lecturers Table
Definition: Creates the Lecturers table linked to the School table via
scho_id.
Create Course_Lecturer Table
Definition: Creates the Course_Lecturer table to establish a many-
tomany relationship between Courses and Lecturers.
Create Students Table
Definition: Creates the Students table linked to the Program table via
pro_id.
Create Enrollments Table
Definition: Creates the Enrollments table to link students to courses.
Insert Data into Faculty Table
Definition: Inserts faculty records into the Faculty table.
Insert Data into School Table
Definition: Inserts school records into the School table, associating them with
faculties.
Insert Data into Program Table
Definition: Inserts program records into the Program table, associating them with
schools.
Insert Data into Courses Table
Definition: Inserts course records into the Courses table, linking them to programs.
Insert Data into Lecturers Table
Definition: Inserts lecturer records into the Lecturers table, associating them
with schools.
Insert Data into Course_Lecturer Table
Definition: Links courses with lecturers in the Course_Lecturer table.
Insert Data into Students Table
Definition: Inserts student records into the Students table, linking them to
programs.
Insert Data into Enrollments Table
Definition: Links students to courses in the Enrollments table.
DIAGRAM
DCL
CREATE DATABASE tcl;
Creates a new database named tcl.
USE tcl;
Selects the tcl database for future operations.
CREATE TABLE std_info(...);
Creates the std_info table with columns ID, NAME, AGE, and BATCH.
INSERT INTO std_info ...;
Inserts data into the std_info table.
SELECT * FROM std_info;
Retrieves all rows and columns from the std_info table.
database in my squel assignment for students.pdf
CREATE USER 'ali'@'localhost' IDENTIFIED BY 'ali1';
Creates a new user ali with password ali1. GRANT
SELECT ON tcl.std_info TO 'ali'@'localhost';
Grants ali permission to read data from std_info.
REVOKE INSERT ON tcl.std_info FROM 'ahmed'@'localhost';
Removes the INSERT permission from ahmed.
FLUSH PRIVILEGES;
Applies privilege changes.
SELECT User, Host FROM mysql.user ...;
Lists users ali, ahmed, and kabeer from the MySQL server.
SHOW GRANTS FOR 'ali'@'localhost';
Displays the privileges granted to ali.
TCL
CREATE TABLE
Definition: Creates a new table with specified columns.
SELECT @@autocommit
Definition: Checks the autocommit mode status.
SET autocommit = 0
Definition: Disables autocommit mode so transactions must be manually
committed.
START TRANSACTION
Definition: Begins a new transaction.
INSERT INTO
Definition: Inserts new data into a table.
SELECT * FROM
Definition: Retrieves all data from a table.
ROLLBACK
Definition: Undoes all changes made in the current transaction.
COMMIT
Definition: Permanently saves all changes made in the current transaction.
UPDATE
Definition: Modifies existing data in a table.
SAVEPOINT
Definition: Creates a checkpoint in a transaction, allowing rollback to this
point.
ROLLBACK TO SAVEPOINT
Definition: Rolls back changes to a specific savepoint without affecting earlier
changes.

More Related Content

PPT
SQL.ppt
PDF
SQL for data scientist And data analysist Advanced
PPTX
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
PPTX
rdbms parul university oracle dbms bca mca
PPTX
Its about a sql topic for basic structured query language
PPT
dbs class 7.ppt
PPT
INTRODUCTION TO SQL QUERIES REALTED BRIEF
SQL.ppt
SQL for data scientist And data analysist Advanced
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
rdbms parul university oracle dbms bca mca
Its about a sql topic for basic structured query language
dbs class 7.ppt
INTRODUCTION TO SQL QUERIES REALTED BRIEF

Similar to database in my squel assignment for students.pdf (20)

PPTX
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
PPT
Db1 lecture4
PPTX
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
PPT
Sql Commands_Dr.R.Shalini.ppt
PPTX
Avinash database
PDF
Database Programming using SQL
PPT
MY SQL
PPT
Mysql 120831075600-phpapp01
PDF
STRUCTURED QUERY LANGUAGE
PDF
23. SQL and Database.pdf
PDF
SQL-Notes.pdf mba students database note
PDF
PDF
Basics on SQL queries
PPT
Mysql
PPTX
MS SQL - Database Programming Concepts by RSolutions
PDF
23. SQL and Database.pdf
PPTX
PPTX
Introduction to database and sql fir beginers
PPT
Ch 9 S Q L
PPTX
23. SQL and Database.pptx this ppt file is important for class 12
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Db1 lecture4
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
Sql Commands_Dr.R.Shalini.ppt
Avinash database
Database Programming using SQL
MY SQL
Mysql 120831075600-phpapp01
STRUCTURED QUERY LANGUAGE
23. SQL and Database.pdf
SQL-Notes.pdf mba students database note
Basics on SQL queries
Mysql
MS SQL - Database Programming Concepts by RSolutions
23. SQL and Database.pdf
Introduction to database and sql fir beginers
Ch 9 S Q L
23. SQL and Database.pptx this ppt file is important for class 12
Ad

Recently uploaded (20)

PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PDF
Introduction to Data Science and Data Analysis
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
PDF
Optimise Shopper Experiences with a Strong Data Estate.pdf
PPT
Predictive modeling basics in data cleaning process
PPTX
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
PPT
DATA COLLECTION METHODS-ppt for nursing research
PDF
Transcultural that can help you someday.
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PDF
How to run a consulting project- client discovery
PDF
Mega Projects Data Mega Projects Data
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
A Complete Guide to Streamlining Business Processes
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PDF
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
PPTX
Managing Community Partner Relationships
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
Pilar Kemerdekaan dan Identi Bangsa.pptx
PPTX
QUANTUM_COMPUTING_AND_ITS_POTENTIAL_APPLICATIONS[2].pptx
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Introduction to Data Science and Data Analysis
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
Optimise Shopper Experiences with a Strong Data Estate.pdf
Predictive modeling basics in data cleaning process
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
DATA COLLECTION METHODS-ppt for nursing research
Transcultural that can help you someday.
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
How to run a consulting project- client discovery
Mega Projects Data Mega Projects Data
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
A Complete Guide to Streamlining Business Processes
Galatica Smart Energy Infrastructure Startup Pitch Deck
STERILIZATION AND DISINFECTION-1.ppthhhbx
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
Managing Community Partner Relationships
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Pilar Kemerdekaan dan Identi Bangsa.pptx
QUANTUM_COMPUTING_AND_ITS_POTENTIAL_APPLICATIONS[2].pptx
Ad

database in my squel assignment for students.pdf

  • 3. Database A database is a collection of information that is organized so it can be easily accessed, managed, and updated. Think of it as a digital storage system where you can keep data, such as names, numbers, or records, and quickly find or change them when needed. For example, a database might store all the contact details for people in a company or all the products in a store SQL SQL (Structured Query Language) is a programming language used to manage and manipulate databases, specifically relational databases. It allows users to create, read, update, and delete data stored in tables. SQL is the standard language for interacting with most relational database systems.
  • 4. Key Functions of SQL: • Create: Make databases and tables. • Read: Retrieve data. • Update: Modify existing data. • Delete: Remove data.
  • 6. Types of SQL Commands: 1. Data Definition Language (DDL) o CREATE: Creates new database objects (e.g., tables). o ALTER: Modifies existing database structures. o DROP: Deletes database objects. o TRUNCATE: Removes all records from a table but keeps the structure. 2. Data Manipulation Language (DML) o SELECT: Retrieves data from the database. o INSERT: Adds new records into a table. o UPDATE: Modifies existing records in a table. o DELETE: Removes records from a table. 3. Data Control Language (DCL) o GRANT: Gives users access to the database. o REVOKE: Removes users' access rights. 4. Transaction Control Language (TCL) o COMMIT: Saves all changes made in the transaction. o ROLLBACK: Reverts changes if something goes wrong. o SAVEPOINT: Sets a point within a transaction to which you can later roll back. 5. Data Query Language (DQL) o SELECT: Used to query and fetch data from the database.
  • 7. 1. CREATE DATABASE o Definition: Creates a new database called student_info. 2. USE DATABASE o Definition: Selects the student_info database to work within it. 3. CREATE TABLE o Definition: Creates a table named student with specified columns such as id, name, age, batch, etc.
  • 8. 4. INSERT INTO o Definition: Inserts records into the student table.
  • 9. 5. SELECT o Definition: Retrieves data from the student table. The asterisk (*) selects all columns, while specific column names like city, name, and age select only those fields.
  • 10. 6. DISTINCT o Definition: Retrieves unique values from the specified column, avoiding duplicates
  • 11. 7. WHERE o Definition: Filters the results based on specified conditions
  • 12. 8. Arithmetic Operators in WHERE o Definition: Uses arithmetic operations within the WHERE clause.
  • 13. 9. Comparison Operators in WHERE o Definition: Compares values using operators like != (not equal) and >= (greater than or equal).
  • 14. 10. Logical Operators (AND) o Definition: Retrieves rows that satisfy both conditions.
  • 15. 11. Logical Operators (OR) o Definition: Retrieves rows that satisfy either of the conditions.
  • 17. Definition 12. BETWEEN o : Selects rows where a column's value falls within a specified range. 13. IN o Definition: Checks if a value exists within a specified set of values.
  • 18. Definition 14. NOT IN o : Selects rows where a value is not part of the specified set.
  • 19. Definition 15. LIMIT Definition: Limits the number of rows returned by the query. 16. ORDER BY o : Sorts the result set by the specified column (ascending or descending).
  • 20. Definition 17. COUNT (Aggregate Function) o Definition: Returns the number of rows that match a specified condition.
  • 21. 18. MAX (Aggregate Function) o Definition: Returns the maximum value of the specified column. 19. MIN (Aggregate Function) o Definition: Returns the minimum value of the specified column. 20. AVG (Aggregate Function) o Definition: Returns the average value of a numeric column.
  • 22. 21. SUM (Aggregate Function) o Definition: Returns the total sum of a numeric column. 22. GROUP BY o Definition: Groups rows with the same values into summary rows.
  • 23. 23. HAVING o Definition: Filters rows after the GROUP BY using aggregate conditions. 24. UPDATE o Definition: Updates existing records in a table.
  • 24. 25. DELETE o Definition: Deletes records from the table based on the condition. 26. ALTER TABLE o Definition: Modifies the structure of an existing table (adding, renaming, modifying, or removing columns).
  • 27. 27. TRUNCATE o Definition: Removes all rows from a table without deleting the table itself. 28. VIEW o Definition: Creates a virtual table based on the result of a SELECT query.
  • 28. 29. AS (Alias) o Definition: Provides an alias to column names.
  • 29. 30. LIKE o Definition: Retrieves rows where a column matches a specified pattern.
  • 30. Joins Create Database Creates a new database named joins. Use Database Selects the joins database for subsequent queries. Create Table – std_table Creates a std_table table with columns for student ID, name, and city. Create Table – sub_table Creates a sub_table table with columns for student ID and subject name.
  • 31. Insert Data into std_table Inserts student records into the std_table table. Insert Data into sub_table Inserts subject records into the sub_table table.
  • 32. Select all from std_table Retrieves all records from the std_table table.
  • 33. Select all from sub_table Retrieves all records from the sub_table table.
  • 34. Inner Join std_table and sub_table Returns matching records from both student and sub where std_id is the same in both tables. Left Join std_table and sub_table
  • 35. Returns all records from the std_table table and matching records from sub_table (if any). Right Join std_table and sub_table Returns all records from the sub_table table and matching records from std_table (if any) Cross Join std_table and sub_table Returns the Cartesian product of the std_table and sub_table tables (all combinations).
  • 36. ER DIAGRAM Create Database Definition: This query creates a new database named university_info. Select Database Definition: This query selects the university_info database for use. Create Faculty Table Definition: Creates the Faculty table with columns fac_id and faculty_name. Create School Table Definition: Creates the School table linked to the Faculty table via fac_id. Create Program Table Definition: Creates the Program table linked to the School table via scho_id.
  • 38. Definition: Creates the Courses table linked to the Program table via pro_id. Create Lecturers Table Definition: Creates the Lecturers table linked to the School table via scho_id. Create Course_Lecturer Table Definition: Creates the Course_Lecturer table to establish a many- tomany relationship between Courses and Lecturers. Create Students Table Definition: Creates the Students table linked to the Program table via pro_id.
  • 39. Create Enrollments Table Definition: Creates the Enrollments table to link students to courses.
  • 40. Insert Data into Faculty Table Definition: Inserts faculty records into the Faculty table. Insert Data into School Table Definition: Inserts school records into the School table, associating them with faculties. Insert Data into Program Table Definition: Inserts program records into the Program table, associating them with schools. Insert Data into Courses Table Definition: Inserts course records into the Courses table, linking them to programs. Insert Data into Lecturers Table Definition: Inserts lecturer records into the Lecturers table, associating them with schools.
  • 41. Insert Data into Course_Lecturer Table Definition: Links courses with lecturers in the Course_Lecturer table. Insert Data into Students Table Definition: Inserts student records into the Students table, linking them to programs. Insert Data into Enrollments Table Definition: Links students to courses in the Enrollments table.
  • 42. DIAGRAM DCL CREATE DATABASE tcl; Creates a new database named tcl. USE tcl; Selects the tcl database for future operations. CREATE TABLE std_info(...); Creates the std_info table with columns ID, NAME, AGE, and BATCH. INSERT INTO std_info ...; Inserts data into the std_info table. SELECT * FROM std_info; Retrieves all rows and columns from the std_info table.
  • 44. CREATE USER 'ali'@'localhost' IDENTIFIED BY 'ali1'; Creates a new user ali with password ali1. GRANT SELECT ON tcl.std_info TO 'ali'@'localhost'; Grants ali permission to read data from std_info. REVOKE INSERT ON tcl.std_info FROM 'ahmed'@'localhost'; Removes the INSERT permission from ahmed. FLUSH PRIVILEGES; Applies privilege changes. SELECT User, Host FROM mysql.user ...; Lists users ali, ahmed, and kabeer from the MySQL server. SHOW GRANTS FOR 'ali'@'localhost'; Displays the privileges granted to ali.
  • 45. TCL CREATE TABLE Definition: Creates a new table with specified columns. SELECT @@autocommit Definition: Checks the autocommit mode status. SET autocommit = 0 Definition: Disables autocommit mode so transactions must be manually committed. START TRANSACTION Definition: Begins a new transaction. INSERT INTO Definition: Inserts new data into a table. SELECT * FROM Definition: Retrieves all data from a table. ROLLBACK Definition: Undoes all changes made in the current transaction. COMMIT Definition: Permanently saves all changes made in the current transaction.
  • 46. UPDATE Definition: Modifies existing data in a table. SAVEPOINT Definition: Creates a checkpoint in a transaction, allowing rollback to this point.
  • 47. ROLLBACK TO SAVEPOINT Definition: Rolls back changes to a specific savepoint without affecting earlier changes.