0% found this document useful (0 votes)
19 views40 pages

Dbms

Uploaded by

iroyharshkumar
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)
19 views40 pages

Dbms

Uploaded by

iroyharshkumar
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/ 40

PROGRAM 1

Installing ORACLE/ MYSQL/NOSQL.


PROGRAM 2
Crea ng En ty-Rela onship Diagram using case tools with Iden fying
(En es, a ributes, keys and rela onships between en es, cardinali es, generaliza on,
specializa on etc.)

ER DIAGRAM ON LIBRARY MANAGEMENT SYSTEM


PROGRAM 3
1. Implement DDL commands –Create, Alter, Drop etc.
2. Implement DML commands- Insert, Select, Update, Delete

DDL COMMANDS
CREATE :- create command is use for crea ng database and also use to create a table
ALTER :- The ALTER command in SQL DDL is used to modify the structure of an already exis ng table

DROP :- The DROP command is a type of SQL DDL command, that is used to delete an exis ng database or an
object within a database.
TRUNCATE :- The TRUNCATE command in SQL DDL is used to remove all the records from a table. Let’s insert
a few records in the Books table
DML COMMANDS
INSERT :- The INSERT statement is used to insert a new row in the database that is adding data to a table.

SELECT :- The SELECT statement is used to retrieve record from one or more tables.

UPDATE :- To update a table or row or column in the table we use the update command.
DELETE :- The DELETE statement is used to delete a row from the table in the database.
PROGRAM 4
1. Implement DCL commands-Grant and Revoke
2. Implement TCL commands- Rollback, Commit, Save point
3. Implement different type key: -Primary Key, Foreign Key and Unique
etc. GRANT :- Used to provide any user access privileges or other privileges for the
database.

REVOKE :- USED TO TAKE BACK PERMISSIONS FROM ANY USER.

2. COMMIT :- COMMIT command is used to permanently save any transac on into the database.
ROLLBACK :- ROLLBACK is a command that causes all data changes since the last BEGIN WORK , or
START TRANSACTION to be discarded by the relational database management systems

SAVEPOINT :- SAVEPOINT command is used to temporarily save a transac on so that you can rollback to
that point whenever required.
3. PIMARY KEY :- A Primary Key is the minimal set of attributes of a table that has the
task to uniquely identify the rows
FOREIGN KEY :- it is the one that is used to link two tables together via the primary key
UNIQUE KEY :- it is a column or set of columns that uniquely identify each record in a table.
PROGRAM 5
Conver ng ER Model to Rela onal Model (Represent en es and rela onships in Tabular
form, represent a ributes as columns, iden fying keys).
There are some rules for conver ng the ER diagram into tables which are as follows:
Rule1: Conversion of an en ty set into a table
a) Representa on of Strong en ty set with simple a ributes
PROGRAM 6
Prac ce Queries using COUNT, SUM, AVG, MAX, MIN, GROUP BY, HAVING, VIEWS Crea on
and Dropping.
COUNT:- The COUNT() function returns the number of rows that matches a specified criteria.
SUM:- SUM() function is an aggregate function that calculates the sum of all or distinct values in
an expression
AVG:- The AVG() function provides the average value of a numeric column.
MAX:- MAX() is used to find the maximum value or highest value of a certain column or expression.
MIN:- The MIN() function returns the smallest value of the selected column.
GROUP BY:- The GROUP BY statement groups rows that have the same values into summary rows
HAVING:- A HAVING clause in SQL specifies that an SQL SELECT statement must only return rows
where aggregate values meet the specified conditions.
VIEWS Crea on:- A view is created with the CREATE VIEW statement.
PROGRAM 7
Prac cing Queries using ANY, ALL, IN, EXISTS, NOT EXISTS, UNION, INTERSECT,
CONSTRAINTS etc.
ANY:- ANY return true if any of the subqueries values meet the condition.
ALL:- ALL operator is used to select all tuples of SELECT STATEMENT

IN:- allows you to easily test if an expression matches any value in a list of values
EXISTS:- The EXISTS operator is used to test for the existence of any record in a subquery.

NOT EXISTS:- It is used to restrict the number of rows returned by the SELECT Statement.

UNION:- It is used to combine the result set of two select queries

INTERSECT:- is used to combine two SELECT statements, but returns rows only from the
first SELECT statement that are identical to a row in the second SELECT statement.
CONSTRAINTS:- Constraints are used to limit the type of data that can go into a table.
Prac cing Sub queries (Nested, Correlated) and Joins (Inner, Outer and Equi).
PROGRAM 9
Practicing on Triggers - crea on of trigger, Inser on using trigger, Dele on
using trigger, Upda ng using trigger
Procedures- Crea on of Stored Procedures, Execu on of Procedure, and Modifica on of
Procedure
Cursors- Declaring Cursor, Opening Cursor, Fetching the data, closing the cursor.
Declaring the cursor:

Cursor <cursor_name> is <select statement>;

Opening the Cursor:

Open <cursor_name>;

Fetching Data from the Cursor:

Fetch <cursor_name> into <record_list>;

Closing the Cursor:

Close <cursor_name>;

EXAMPLE:
Declare
Create cursor cur_emp is select ename,Salary from em
nm emp.ename%type;
salemp.salary%type;
Begin open cur_emp;
fetch cur_emp into nm,sal;
dbms_output.put_line(‘Name : ‘ || nm);
dbms_output.put_line(‘Salary :‘ || sal);
close cur_emp;
End;
PROGRAM 12
Study of Open Source NOSQL Database: MongoDB (Installa on, Basic CRUD opera ons,
Execu on)

Objec ve:

1. To learn and understand NOSQL Database.


2. To execute CRUD Opera ons on MongoDB.

Hardware requirements:
Any CPU with Pen um Processor or similar, 256 MB RAM or more, 1
GB Hard Disk or more.
So ware requirements:
Ubuntu 14.04, Mongodb Packages

Theory:

MongoDB is a free and open-source NoSQL document database used commonly in

modern web applica ons. MongoDB works on concept of collec on and document.

Collec on
Collec on is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collec on

exists within a single database. Collec ons do not enforce a schema.

Document
A document is a set of key-value pairs. Documents have dynamic schema. Dynamic schema means that

documents in the same collec on do not need to have the same set of fields or structure, and

common fields in a collec on's documents may hold different types of data.
CRUD Opera ons:

CRUD opera ons create, read, update, and delete documents.

These opera ons are considered to be the four basic func onali es of a repository

. CRUD opera ons can be mapped directly to database opera ons:

• Create matches insert


• Read matches select
• Update matches update
• Delete matches delete
1. Create Operations
db.collec on.insert()

EXAMPLE:

1) db.products.insert( { item: "card", qty: 15 } ) Will

store record(document) as

{ "_id" : ObjectId("5063114bd386d8fadbd6b004"), "item" : "card", "qty" : 15 }


2) db.products.insert( { _id: 10, item: "box", qty: 20 } ) Will
store record (document) as

db.products.insert( { _id: 10, item: "box", qty: 20 } )

2. Read Opera ons


EXAMPLE:
db.products.find( { qty: { $gt: 25 } } )

3. Update Opera ons


db.COLLECTION_NAME.update(SELECTION_CRITERIA, UPDATED_DATA)

EXAMPLE:
Consider the mycol collec on has the following data.

Following example will set the new tle 'New MongoDB Tutorial' of the documents whose tle is
'MongoDB Overview'.
4. Delete Opera on:
db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
EXAMPLE:
Consider the mycol collec on has the following data.

Following example will remove all the documents whose tle is 'MongoDB Overview'.
PROGRAM 13
Design and Develop MongoDB Queries using CRUD opera ons. (Use CRUD opera ons,
SAVE method, logical operators)

MongoDB Save() Method:


db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA})
EXAMPLE:
Logical Oerators in MongoDB:

Name Description

$and

Joins query clauses with a logical AND returns all documents that match the conditions of
both clauses.

$not Inverts the effect of a query expression and returns documents that do not match the query
expression.

$nor Joins query clauses with a logical NOR returns all documents that fail to match both
clauses.

$or

Joins query clauses with a logical OR returns all documents that match the conditions of
either clause
PROGRAM 14
Implement aggrega on and indexing with suitable example using MongoDB.

Objec ves : Learn the concept of MongoDB

Theory : MongoDB is an open-source document database and leading NoSQL database.


MongoDB is wri en in C++. This tutorial will give you great understanding on MongoDB concepts
needed to create and deploy a highly scalable and performance-oriented database.

Aggrega ons opera ons process data records and return computed results. Aggrega on opera ons
group values from mul ple documents together, and can perform a variety of opera ons on the
grouped data to return a single result. In SQL count(*) and with group by is an equivalent of
mongodb aggrega on. The aggregate() Method For the aggrega on in MongoDB, you should use
aggregate() method.

Basic syntax of aggregate() method is as follows:

>db.COLLECTION_NAME.aggregate(AGGREGATE_OPERATION)

Example

In the collec on you have the following data:


{
_id: ObjectId(7df78ad8902c) tle: 'MongoDB Overview', descrip on: 'MongoDB is no sql database',
by_user: 'niet_ point', url: 'h p://www.niet_point.com', tags: ['mongodb', 'database', 'NoSQL'], likes:
100
},
{
_id:

ObjectId(7df78ad8902d) tle:

'NoSQL Overview',

descrip on: 'No sql database

is very fast', by_user: 'niet_ point', url:


h p://www.niet_point.co

m', tags: ['mongodb',

'database', 'NoSQL'], likes:

},
{
_id:
ObjectId(7df78ad8902e) tle: 'Neo4j Overview', descrip on: 'Neo4j is no sql database', by_user:'Neo4j',
url:'h p://www.neo4j.com', tags: ['neo4j', 'database', 'NoSQL'], likes: 750
},

Now from the above collec on, if you want to display a list sta ng how many niet_ are wri en by each
user, then you will use the following aggregate() method:
> db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum :1}}}])
{
"result" : [
{
"_id" : "niet_ point", "num_tutorial" : 2
},
{
"_id" : "Neo4j","num_tutorial" : 1
}],
"ok" : 1
}>
Sql equivalent query for the above use case will be select by_user, count(*) from mycol group by
by_user.

Pipeline Concept:

In UNIX command, shell pipeline means the possibility to execute an opera on on some input and
use the output as the input for the next command and so on. MongoDB also supports same
concept in aggrega on framework. There is a set of possible stages and each of those is taken as a
set of documents as an input and produces a resul ng set of documents (or the final resul ng
JSON document at the end of the pipeline). This can then in turn be used for the next stage and so
on.

Following are the possible stages in aggrega on framework:

• $project: Used to select some specific fields from a collec on.


• $match: This is a filtering opera on and thus this can reduce the amount of documents that
are given as input to the next stage.

• $group: This does the actual aggrega on as discussed above.

• $sort: Sorts the documents.

• $skip: With this, it is possible to skip forward in the list of documents for a given amount of
documents.

• $limit: This limits the amount of docu ments to look at, by the given number star ng from the
current posi ons.
• $unwind: This is used to unwind document that are using arrays. When using an array, the data is
kind of pre-joined and this opera on will be undone with this to have individual documents again.
Thus with this stage we will increase the amount of documents for the next stage.

Indexes support the efficient resolu on of queries. Without indexes, MongoDB must scan every
document of a collec on to select those documents that match the query statement This scan is
highly inefficient and require MongoDB to process a large volume of data.

Indexes are special data structures, that store a small por on of the data set in an easy -to-traverse
form. The index stores the value of a specific field or set of fields, ordered by the value of the field
as specified in the index.

The ensureIndex() Method

To create an index you need to use ensureIndex() method of MongoDB. The basic syntax of
ensureIndex() method is as follows().

>db.COLLECTION_NAME.ensureIndex({KEY:1})

Here key is the name of the file on which you want to create index and 1 is for ascending order. To
create index in descending order you need to use -1.

Example

>db.mycol.ensureIndex({" tle":1})

In ensureIndex() method you can pass mul ple fields, to create index on mul ple fields.

>db.mycol.ensureIndex({" tle":1,"descrip on":-1}) ensureIndex() method also

accepts list of op ons (which are op onal). Following is the list:


PROGRAM 15
Mini project (Design & Development of Data and Applica on) for following: -
a) Inventory Control System.
b) Material Requirement Processing.
c) Hospital Management System.
d) Railway Reserva on System.
e) Personal Informa on System.
f) Web Based User Iden fica on System.
g) Timetable Management System.
h) Hotel Management System

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy