0% found this document useful (0 votes)
21 views17 pages

DBMS Journal

1. The document discusses various SQL concepts like conceptual modeling using ER diagrams, creating and manipulating databases and tables, performing queries with joins, aggregates and subqueries, views, and security. 2. Key tasks covered include creating databases and tables, inserting/updating/deleting records, altering tables, backups and restoring, aggregation functions, date/string functions, inner/outer joins, subqueries with IN and EXISTS, normalization up to 3NF, creating views with and without check options, and granting/revoking permissions. 3. The document provides examples of SQL statements to implement these concepts and tasks.

Uploaded by

MAYURESH KASAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views17 pages

DBMS Journal

1. The document discusses various SQL concepts like conceptual modeling using ER diagrams, creating and manipulating databases and tables, performing queries with joins, aggregates and subqueries, views, and security. 2. Key tasks covered include creating databases and tables, inserting/updating/deleting records, altering tables, backups and restoring, aggregation functions, date/string functions, inner/outer joins, subqueries with IN and EXISTS, normalization up to 3NF, creating views with and without check options, and granting/revoking permissions. 3. The document provides examples of SQL statements to implement these concepts and tasks.

Uploaded by

MAYURESH KASAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

DBMS Journal

Sr.
Index Date Sign
No.
Conceptual Designing using ER Diagrams (Identifying entities,
1 attributes, keys and relationships between entities,
cardinalities, generalization, specialization etc.)
Perform the following:
1. Viewing all databases
2. Creating a Database
2 3. Viewing all Tables in a Database
4. Creating Tables (With and Without Constraints)
5. Inserting/Updating/Deleting Records in a Table
Perform the following:
1. Altering a Table
3 2. Dropping/Truncating/Renaming Tables
3. Backing up / Restoring a Database
Perform the following:
4 1. Simple Queries
2. Simple Queries with Aggregate functions
Queries involving:
1. Date Functions
5 2. String Functions
3. Math Functions
Join Queries:
6 1. Inner Join
2. Outer Join
Subqueries:
7 1. With IN clause
2. With EXISTS clause
Converting ER Model to Relational Model and apply
Normalization on database. (Represent entities and
8 relationships in Tabular form, Represent attributes as columns,
identifying keys and normalization up to 3rd Normal Form).
Views:
1. Creating Views (with and without check option)
9 2. Dropping views
3. Selecting from a view
DCL statements:
10 1. Granting and revoking permissions
2. Saving (Commit) and Undoing (rollback)
1. Conceptual Designing using ER Diagrams (Identifying entities, attributes, keys
and relationships between entities, cardinalities, generalization, specialization etc.)
2. Perform the following:
1. Viewing all database
SHOW DATABASES;

2. Creating a database
CREATE DATABSE SPDC;

3. Viewing all tables in a database


SHOW TABLES;

4. Creating tables (with and without constrains)


A. Creating tables with constrains
CREATE TABLE STUDENTS(ROLLNO INT PRIMARY KEY, FNAME
VARCHAR(20), LNAME VARCHAR(50), AGE INT, SEX CHAR(1), PNO
INT(10));
B. Creating tables without constrains
CREATE TABLE STUDENTS(ROLLNO INT, FNAME VARCHAR(20),
LNAME VARCHAR(50), AGE INT, SEX CHAR(1), PNO INT(10));

5. Inserting/Updating/Deleting Records in a table


A. Inserting record in table
INSERT INTO STUDENTS
VALUES(90,"Satish","Vishwakarma",20,"M",9867694223);

B. Updating record in a table


UPDATE STUDENTS SET AGE=18 WHERE ROLLNO=90;

C. Deleting record in a table


DELETE FROM STUDENTS WHERE ROLLNO=2;
3. Perform the following:
1. Alter a table
ALTER TABLE STUDENTS ADD COLUMN P_MARKS FLOAT(10);

2. Dropping/Truncating/Renaming tables
a. Dropping table
DROP TABLE STUDENTS;

b. Truncating table
TRUNCATE TABLE STUDENTS;

c. Renaming table
ALTER TABLE STUDENTS RENAME TO STUD;
3. Backup / Restoring a database
a. Backup a database
MYSQL -U ROOT -P SPDC > SPDC.SQL;
b. Restoring a database
MYSQL -U ROOT -P SPDC < SPDC.SQL;
4. Perform the following:
1. Simple quires
SELECT * FROM STUDENTS WHERE AGE<=18;

2. Simple quires with aggregate function


1. Count function
SELECT COUNT(*) AS FNAME FROM STUDENTS WHERE AGE<=18;

2. Average function
SELECT AVG(P_MARKS) AS AVGM FROM STUDENTS WHERE P_MARKS>50;

3. Max function
SELECT MAX(AGE) AS MAX_AGE FROM STUDENTS;

4. Min function
SELECT MIN(AGE) AS MIN_AGE FROM STUDENTS;
5. Sum function
SELECT SUM(P_MARKS+C_MARKS+M_MARKS) AS TOTAL_MARK FROM
STUDENTS WHERE ROLLNO=90;
5. Queries involving:
1. Date functions
SELECT DATE("2019-04-06 09:34:13");

2. String functions
a. SELECT ASCII("V");

b. SELECT BIN(13);

c. SELECT BIT_LENGTH("Test");

d. SELECT CHAR_LENGTH("Test");

e. SELECT CONCAT("V", "Satish");

3. Maths functions
a. SELECT PI();
b. SELECT POW(3,2);

c. SELECT 4 % 3;

d. SELECT LOG10(13);
6. Join Queries
1. Inner join
SELECT ORDERS.OID, CUSTOMERS.CNAME FROM ORDERS INNER JOIN
CUSTOMERS ON ORDERS.CID = CUSTOMERS.CID;

2. Outer join
SELECT ORDERS.OID, CUSTOMERS.CNAME FROM ORDERS JOIN
CUSTOMERS ON ORDERS.CID = CUSTOMERS.CID;
7. Subquries
1. With IN clause
SELECT * FROM CUSTOMERS WHERE CID IN (SELECT CID FROM ORDERS
WHERE PSTATUS = "PAID");

2. With EXISTS clause


SELECT CID FROM CUSTOMERS WHERE EXISTS (SELECT CID FROM ORDERS
WHERE PSTATUS = "PAID");
8. Converting ER Model to Relational Model and apply Normalization on database.
(Represent entities and relationships in Tabular form, Represent attributes as
columns, identifying keys and normalization up to 3rd Normal Form).
1. UNF
LecturerNumber, LecturerName, LecturerGrade, DepartmentCode,
DepartmentName
LecturerNumber LecturerName LecturerGrade DepartmentCode DepartmentName
101 Raju A,B 404,401 IT,CS
102 Ram B 420 CS

2. 1NF
LecturerNumber, SubjectCode, SubjectName, SubjectLevel
LecturerNumber SubjectCode SubjectName SubjectLevel
101 2444 OOPs 1
101 2135 Calculus 3
102 1446 DBMS 2

3. 2NF
LecturerNumber, LecturerName, LecturerGrade, DepartmentCode,
DepartmentName
LecturerNumber, SubjectCode
SubjectCode, SubjectName, SubjectLevel
LecturerNumber LecturerName LecturerGrade DepartmentCode DepartmentName
101 Raju A 404 IT
101 Raju B 401 CS
102 Ram B 420 CS

LecturerNumber SubjectCode
101 2444
101 2135
102 1446

SubjectCode SubjectName SubjectLevel


2444 OOPs 1
2135 Calculus 3
1446 DBMS 2
4. 3NF
LecturerNumber, LecturerName, LecturerGrade
LecturerNumber LecturerName LecturerGrade
101 Raju A
101 Raju B
102 Ram B

DepartmentCode, DepartmentName
DepartmentCode DepartmentName
404 IT
401 CS
420 CS

LecturerName, SubjectCode
LecturerName SubjectCode
Raju 2444
Raju 2135
Ram 1446

SubjectCode, SubjectName, SubjectLevel


SubjectCode SubjectName SubjectLevel
2444 OOPs 1
2135 Calculus 3
1446 DBMS 2
9. Views
1. Creating view (with and without check option)
a. Creating view with check option
CREATE VIEW VTEST AS SELECT CID, OID FROM ORDERS WITH
CHECK OPTION;

b. Creating view without check option


CREATE VIEW VTEST AS SELECT CID, OID FROM ORDERS;

2. Dropping view
DROP VIEW VTEST;

3. Selecting from view


SELECT * FROM VTEST;
10. DCL statements
1. Granting and revoking permissions
a. Granting permissions
GRANT SELECT, UPDATE ON ORDERS TO 'chotabheem'@'localhost';

b. Revoking permissions
REVOKE UPDATE ON ORDERS FROM 'chotabheem'@'localhost';

2. Saving (Commit) and Undoing (Rollback)


a. Saving
DELETE FROM STUDENTS WHERE ROLLNO=90;
COMMIT;

b. Undoing
ROLLBACK;

You might also like