0% found this document useful (0 votes)
17 views62 pages

Cs3481-Dbms Lab Manual

The document is a lab manual for the Database Management System Laboratory course at SRI Muthukumaran Institute of Technology for the academic year 2024-2025. It outlines course objectives, a list of experiments, and expected outcomes, focusing on SQL commands, database design, and application development. Students will learn to create and manipulate databases, implement constraints, and develop GUI-based applications using various database tools.

Uploaded by

shariprasath205
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)
17 views62 pages

Cs3481-Dbms Lab Manual

The document is a lab manual for the Database Management System Laboratory course at SRI Muthukumaran Institute of Technology for the academic year 2024-2025. It outlines course objectives, a list of experiments, and expected outcomes, focusing on SQL commands, database design, and application development. Students will learn to create and manipulate databases, implement constraints, and develop GUI-based applications using various database tools.

Uploaded by

shariprasath205
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/ 62

1

SRI MUTHUKUMARAN INSTITUTE OF TECHNOLOGY


Chikkarayapuram, Near Mangadu, Chennai – 600 069.
Academic Year 2024-2025 / Even Semester

DEPARTMENT OF INFORMATION TECHNOLOGY

SUB CODE : CS3481


SUBNAME : DATABASE MANAGEMENT SYSTEM LABORATORY

LAB MANUAL
REGULATION:2021
2

CS3481 DATABASE MANAGEMENT SYSTEMS LABORATORY LTPC


0 0 3 1.5
COURSE OBJECTIVES:
To learn and implement important commands in SQL.
To learn the usage of nested and joint queries.
To understand functions, procedures and procedural extensions of databases.
To understand design and implementation of typical database applications.
To be familiar with the use of a front end tool for GUI based application development.
LIST OF EXPERIMENTS:
1. Create a database table, add constraints (primary key, unique, check, Not null), insert rows,
update and delete rows using SQL DDL and DML commands.
2. Create a set of tables, add foreign key constraints and incorporate referential integrity.
3. Query the database tables using different ‘where’ clause conditions and also implement
aggregate functions.
4. Query the database tables and explore sub queries and simple join operations.
5. Query the database tables and explore natural, equi and outer joins.
6. Write user defined functions and stored procedures in SQL.
7. Execute complex transactions and realize DCL and TCL commands.
8. Write SQL Triggers for insert, delete, and update operations in a database table.
9. Create View and index for database tables with a large number of records.
10. Create an XML database and validate it using XML schema.
11. Create Document, column and graph based data using NOSQL database tools.
12. Develop a simple GUI based database application and incorporate all the above-mentioned
features
13. Case Study using any of the real life database applications from the following list
a) Inventory Management for a EMart Grocery Shop
b) Society Financial Management
c) Cop Friendly App – Eseva
d) Property Management – eMall
e) Star Small and Medium Banking and Finance
● Build Entity Model diagram. The diagram should align with the business and
functional goals stated in the application
● Apply Normalization rules in designing the tables in scope.
● Prepared applicable views, triggers (for auditing purposes), functions for
enabling enterprise grade features.
● Build PL SQL / Stored Procedures for Complex Functionalities, ex EOD Batch
Processing for calculating the EMI for Gold Loan for each eligible Customer.
● Ability to showcase ACID Properties with sample queries with appropriate
settings
List of Equipments:(30 Students per Batch)
MYSQL / SQL : 30 Users
TOTAL: 45 PERIODS
COURSE OUTCOMES:
At the end of this course, the students will be able to:
CO1: Create databases with different types of key constraints.
CO2: Construct simple and complex SQL queries using DML and DCL commands.
CO3: Use advanced features such as stored procedures and triggers and incorporate in GUI based
application development.
CO4: Create an XML database and validate with meta-data (XML schema).
CO5: Create and manipulate data using NOSQL database.
3

LIST OF EXPERIMENTS

EXPERIMENT PAGE
EXPERIMENT NAME
NUMBER NO
a) IMPLEMENTATION OF DDL COMMANDS
b) IMPLEMENTATION OF CONSTRAINTS USING DDL
EX NO :1
/ DML COMMANDS
c) IMPLEMENTATION OF DML COMMANDS
EX NO: 2 IMPLEMENTATION OF REFERENTIAL INTEGRITY
a) QUERY THE DATABASE TABLES
EX NO : 3
USING DIFFERENT ‘WHERE’ CLAUSE CONDITIONS
b) IMPLEMENTATION OF AGGREGATE FUNCTIONS
a) QUERY THE DATABASE TABLES AND EXPLORE
EX.NO : 4 SUB QUERIES
b) QUERY THE DATABASE TABLES AND EXPLORE
SIMPLE JOIN OPERATIONS
NATURAL JOIN, EQUI JOIN AND OUTER JOINS
EX.NO : 5
OPERATIONS
a) USER DEFINED FUNCTIONS
EX.NO : 6
b) STORED PROCEDURES
a) TCL COMMANDS(GRANT & REVOKE )
EX.NO : 7 b) TCL COMMANDS(COMMIT, SAVEPOINT AND
ROLLBACK)

EX.NO : 8 TRIGGERS
a) CREATION OF VIEW
EX.NO : 9
b) CREATION OF INDEX

EX.NO : 10 XML DATABASE

EX.NO : 11 NOSQL DATABASE TOOLS

EX .NO : 12 PAYROLL PROCESSING SYSTEM


DATABASE DESIGN USING ER MODELING,
NORMALIZATION AND IMPLEMENTATION FOR
EX.NO : 13 INVENTORY MANAGEMENT FOR A EMART GROCERY
SHOP
4

EX NO: 1 a)
IMPLEMENTATION OF DDL COMMANDS
DATE :

AIM:
To implement DML commands using SQL.
 CREATE TABLE
 ALTER TABLE
 DROP TABLE

PROCEDURE:

Step 1 : Create database named as “student_database ”


Step 2 : Create a table named as “student”
Step 3 : Display the structure of table using dt <table_name>
Step 4 : Insert the data into table using insert query.
Step 5: Alter the structure of table using alter command.
Step 6 : Drop the table using drop command
Step 7 : Display the desired output in neat format.
Step 8 : Stop the program

QUERIES & OUTPUT:

CREATING DATABASE: “STUDENT_DATABASE ”


5

CREATING TABLE - “STUDENT”

DISPLAY THE STRUCTURE OF TABLE –“ STUDENT “

USING ALTER COMMAND: Adding Extra column to Existing Table

USING ALTER COMMAND: Drop the existing column from Existing Table
6

DELETE TH E TABLE USING DROP COMMAND:

RESULT :

Thus the database and table were created and SQL DDL commands were executed
successfully.
7

EX NO: 1 b) IMPLEMENTATION OF CONSTRAINTS USING DDL / DML


DATE : COMMANDS

AIM:
To implement primary key constraint, unique constraint, check constraint, NOT NULL
constraint using DDL / DML commands.

PROCEDURE:

Step 1 : Open postgressql in sqlshell prompt


Step 2 : Create database named as “college”
Step 3 : Create a table named as “employees” with primary key, unique, check, Not null
constraints.
Step 4 : Check primary key, unique, check, Not null constraints using insert query
Step 5 : Display the desired output in neat format.
Step 6 : Stop the program

QUERIES & OUTPUT:

CREATING DATABASE: COLLEGE

Creating TABLE: EMPLOYEES


8

INSERTING DATA INTO TABLE : EMPLOYEES

DISPLAY THE DATA FROM TABLE – EMPLOYEES :

DISPLAY THE STRUCTURE OF TABLE – EMPLOYEES WITH ALL CONSTRAINTS:

CHECKING PRIMARY AND UNIQUE CONSTRAINT:

PRIMARY KEY
The PRIMARY KEY constraint consists of one column or multiple columns with values that
uniquely identify each row in the table
UNIQUE constraint
The UNIQUE constraint in SQL is used to ensure that no duplicate values will be inserted into a
specific column or combination of columns that are participating in the UNIQUE constraint and
not part of the PRIMARY KEY
postgres=# insert into employees(id,first_name,last_name,birth_date,joined_date,salary)
values(1,'ram','kumar','1990-05-08','2001-02-06',70000);

ERROR: duplicate key value violates unique constraint "employees_pkey"


DETAIL: Key (id)=(1) already exists.
9

CHECKING NOT-NULL CONSTRAINT:

Not null constraints


By default, the columns are able to hold NULL values. A NOT NULL constraint in SQL is used
to prevent inserting NULL values into the specified column, considering it as a not accepted value
for that column. This means that you should provide a valid SQL NOT NULL value to that
column in the INSERT or UPDATE statements, as the column will always contain data.
postgres=# insert into employees(id,first_name,last_name,birth_date,joined_date,salary)
postgres-# values(7,NULL,'kumar','1990-05-08','1980-02-06',0);
ERROR: null value in column "first_name" of relation "employees" violates not-
null constraint
DETAIL: Failing row contains (7, null, kumar, 1990-05-08, 1980-02-06, 0).
CHECK Constraint
It is used to restrict the value of a column between a range. It performs check on the
values, before storing them into the database. Its like condition checking before saving data into a
column.

CHECKING CHECK CONSTRAINT : [birth_date > '1990-01-01']:

postgres=# insert into employees(id,first_name,last_name,birth_date,joined_date, salary)

values(4,'raj','kumar','1980-05-08','2001-02-06',70000);

ERROR: new row for relation "employees" violates check constraint


"employees_birth_date_check"

DETAIL: Failing row contains (4, raj, kumar, 1980-05-08, 2001-02-06, 70000).

CHECKING CHECK CONSTRAINT :[ joined_date > birth_date]

postgres=# insert into employees(id,first_name,last_name,birth_date,joined_date,salary)


values(4,'raj','kumar','1991-05-08','1990-02-06',70000);
ERROR: new row for relation "employees" violates check constraint
"employees_check"
DETAIL: Failing row contains (4, raj, kumar, 1991-05-08, 1990-02-06, 70000).
CHECKING CHECK CONSTRAINT [ SALARY >0 ] :
postgres=# insert into employees(id,first_name,last_name,birth_date,joined_date,salary)
postgres-# values(6,'raj','kumar','1990-05-08','2021-02-06',0);
ERROR: new row for relation "employees" violates check constraint
"employees_salary_check"
DETAIL: Failing row contains (6, raj, kumar, 1990-05-08, 2021-02-06, 0).
postgres=#

RESULT:

Thus primary key constraint, unique constraint, check constraint, NOT NULL constraint
was implemented using DDL / DML commands and executed successfully.
10

EX NO: 1 C
DATE : IMPLEMENTATION OF DML COMMANDS

AIM:
To implement DML commands using SQL.
 INSERT
 DELETE
 UPDATE
PROCEDURE:
Step 1 : Open postgressql in sqlshell prompt
Step 2 : Create database named as “college”
Step 3 : Create a table named as “employees” with constraints.
Step 4 : Insert the data into table using insert query.
Step 5 : Update the data into table using update query.
Step 6 : Delete the data from table using delete query.
Step 7 : Display the desired output in neat format.
Step 8 : Stop the program

QUERIES & OUTPUT:

CREATING DATABASE: COLLEGE

Creating TABLE: EMPLOYEES


11

INSERTING DATA INTO TABLE : EMPLOYEES

DISPLAY THE DATA FROM TABLE – EMPLOYEES :

UPDATE THE DATA IN TABLE :


BEFORE UPDATING:

AFTER UPDATION
12

DELETING THE DATA FROM TABLE – EMPLOYEES:

BEFORE DELETION:

AFTER DELETION:

RESULT :

Thus the database and table was created and DML commands were executed successfully.
13
EX NO: 2
DATE : IMPLEMENTATION OF REFERENTIAL INTEGRITY

AIM:

To create a set of tables, add foreign key constraints and incorporate referential integrity using
SQL
PROCEDURE:
Step 1 : Open postgressql in sqlshell prompt
Step 2 : Create customers (base table ) with primary key constraints and contacts
(reference table) with foreign key constraints
Step 3 : Insert the data into table using insert query.
Step 4 : Delete the data from table using delete query with cascading option.
Step 5 : Display the desired output in neat format.
Step 6 : Stop the program

QUERIES & OUTPUT:

CREATION OF CUSTOMERS ( BASE TABLE ) AND CONTACTS (REFERENCE


TABLE)
14

INSERTING DATA INTO TABLES:

DELETION FROM CUSTOMERS (BASE TABLE ) AND CONTACTS (REFERENCE


TABLE) AT SIMULTANEOUSLY

RESULT :

Thus the customers table and contacts table was created. The referential integrity was
incorporated using SQL and executed successfully.
15

Ex no : 3a
QUERY THE DATABASE TABLES
USING DIFFERENT ‘WHERE’ CLAUSE CONDITIONS
Date :
AIM:

To Query the database tables using different ‘WHERE’ clause conditions


PROCEDURE:
Step 1 : Open postgressql in sqlshell prompt
Step 2 : Create employees table
Step 3 : Insert the data into table using insert query.
Step 4 : Query the employees table using different ‘where’ clause conditions
Step 5 : Display the desired output in neat format.
Step 6 : Stop the program

QUERIES & OUTPUT:


16
17

RESULT :

Thus the employees’ data extracted using different ‘WHERE’ clause conditions using
SQL and executed successfully.
18

EX NO : 3 B
IMPLEMENTATION OF AGGREGATE FUNCTIONS
DATE :

AIM :

To implement aggregate functions using SQL .

PROCEDURE :

Step 1 : Create employees table


Step 2 : Insert employees details in employee table
Step 3: Find the min, max and average value of salary using min(), max() and avg()
with select query
Step 4: Find the count of the no.of employees in employee table by using count() with
select query
Step 5: Display the desired output in neat format.
Step 6: Stop the program

QUERIES & OUTPUT:


19

RESULT:

Thus the implementation of aggregate functions using SQL was done and output was
verified successfully.
20

Ex.no 4 a)
QUERY THE DATABASE TABLES AND EXPLORE SUB QUERIES
Date :

AIM

To query the database tables and explore sub queries using SQL.

PROCEDURE :

Step 1 : Create employees table


Step 2 : Insert employees details in employee table
Step 3: Write sub query to extract the data from employees table
Step 4: Display the desired output in neat format.
Step 5: Stop the program

QUERIES & OUTPUT:

RESULT :

Thus the sub query was explored and executes successfully using SQL.
21

Ex.no 4 b)
QUERY THE DATABASE TABLES AND EXPLORE SIMPLE JOIN
Date : OPERATIONS

AIM

To query the database tables and explore simple join operations using SQL.

PROCEDURE :

Step 1 : Create employees table


Step 2 : Insert employees details in employee table
Step 3: Write query to extract the data from employees table using join operations
Step 4: Display the desired output in neat format.
Step 5: Stop the program

QUERIES & OUTPUT:

a) INNER JOIN
22

b) LEFT JOIN

c) RIGHT JOIN

RESULT :

Thus the simple joins was explored and executed successfully using SQL.
23

EX.NO : 5
NATURAL JOIN, EQUI JOIN AND OUTER JOINS OPERATIONS
DATE :

AIM

To query the database tables and explore the NATURAL JOIN, EQUI JOIN AND
OUTER JOIN operations using SQL.

PROCEDURE :

Step 1 : Create employees table


Step 2 : Insert employees details in employee table
Step 3: Write query to extract the data from employees table using Natural join, Equi join
and Outer joins operations
Step 4: Display the desired output in neat format.
Step 5: Stop the program

QUERIES & OUTPUT:

a) NATURAL JOIN
24

b) EQUI JOIN

c) FULL OUTER JOIN

d) RIGHT OUTER JOIN


25

e) LEFT OUTER JOIN :

RESULT :

Thus the NATURAL JOIN, EQUI JOIN AND OUTER JOIN operations was explored and
executed successfully using SQL.
26

EX.NO : 6a
USER DEFINED FUNCTIONS
DATE :

AIM

To write user defined functions using SQL.

PROCEDURE :

Step 1 : Create employees table


Step 2 : Insert employees details in employee table
Step 3: Write user defined function named as get_emp_count using SQL.
Step 4 : Check whether user defined function named as get_emp_count created or not
Step 5: Now Call the function using sql select query by passing values
Step 6: Display the desired output in neat format.
Step 7: Stop the program

QUERIES & OUTPUT:

Creating function - get_emp_count:

CHECKING FUNCTION CREATION :

CALLING FUNCTION:
27

LISTING THE EMPLOYEES DETAILS:

RESULT :

Thus the user defined functions was created and executed successfully using SQL.
28

EX.NO : 6b
STORED PROCEDURES
DATE :
AIM

To write stored procedure using SQL.

PROCEDURE :

Step 1 : Create table named as “clothes”


Step 2 : Insert clothes details in clothes table
Step 3: Write procedure named as addcloths using SQL.
Step 4 : Check whether procedure named as addcloths created or not
Step 5: Now Call the procedure using procedure name “ addcloths”
Step 6: Display the desired output in neat format.
Step 7: Stop the program

QUERIES & OUTPUT:

Creation of table: clothes

Creation of stored procedure : Addclothes

Postgres=# Create OR REPLACE PROCEDURE Addclothes (c_ID INOUT INT, C_Name


Postgres=# varchar(100),c_city varchar(100),c_color varchar(100),c_price integer)
Postgres=# LANGUAGE plpgsql AS
Postgres=# $$ BEGIN
Postgres=# INSERT INTO clothes (Name, city,color,Price ) Values (c_Name, c_city, c_color,
c_price )
Postgres=# RETURNING ID INTO c_ID;
Postgres=# END $$;

Checking procedure creation:


29

CALLING PROCEDURE : ADDCLOTHES

DISPLAY THE CLOTHES DETAILS :

RESULT:

Thus the stored procedure was created and executed successfully using SQL.
30

EX.NO : 7 A TCL COMMANDS


DATE : (GRANT & REVOKE )

AIM

To execute complex transactions and realize TCL commands using SQL.

PROCEDURE :

Step 1 : Start the program


Step 2 : Create new user named name guest with password
Step 3: Grant the all privileges to guest user
Step 4 : Logon into guest user
Step 5: Perform the transactions as needed.
Step 6: Logon to admin user and check whether transactions performed.
Step 7: Now revoke all privileges from guest user.
Step 8: Display the desired output in neat format.
Step 9: Stop the program

QUERIES & OUTPUT:

DCL COMMANDS :
31

Login On “ Guest User “ And Updating Employees Table


32

Login on postgres user and verfiying the updation :

CHECKING PRIVILEGES TO GUEST USER :

RESULT :

Thus the previliege was given to another user and complex transactions was executed
using TCL Commands successfully.
33

EX.NO : 7 b TCL COMMANDS


DATE : (COMMIT, SAVEPOINT AND ROLLBACK)

AIM:

To execute complex transactions and realize TCL commands using SQL.

PROCEDURE :

Step 1 : Start the program


Step 2 : Create table named as accounts
Step 3: Insert customers’ accounts details into the table.
Step 4 : Save the transactions by using SAVE POINT COMMAND in a desired point of
transaction
Step 5: Revert the transaction using ROLLBACK COMMAND in a desired point of
transaction.
Step 6: Display the customers’ accounts details and save the details permanently using
COMMIT COMMAND
Step 7: Display the desired output in neat format.
Step 8: Stop the program

QUERIES & OUTPUT:


34

TRANSACTION USING COMMIT COMMAND :

TRANSACTION USING ROLL BACK COMMAND:


35

TRANSACATION USING SAVEPOINT COMMAND :


36

RESULT :

Thus the complex transactions was executed using TCL Commands successfully.
37

EX.NO : 8
TRIGGERS
DATE :
AIM

To write SQL Triggers for insert, delete, and update operations in a database table using
SQL.

PROCEDURE:

Step 1 : Start the program


Step 2 : Create two tables named as COMPANY, AUDIT
Step 3: Create the function named as auditlogfunc( )
Step 4 : Create trigger named as example_trigger for inserting details of employees
details in company table
Step 5: Execute the example_trigger to insert into COMPANY table.
Step 6: Display the desired output in neat format.
Step 7: Stop the program
QUERIES & OUTPUT:

CREATION OF COMPANY TABLE:

CREATION OF AUDIT TABLE:


38

CREATION OF FUNCTION : auditlogfunc()

CREATION OF TRIGGER[example_tiggger]

DISPLAYING OF TRIGGER CREATION:

INSERTING THE DATA INTO THE COMPANY TABLE :


39

DISPLAY THE DATA ENTRY IN COMPANY AND AUDIT TABLE:

RESULT:

Thus the trigger was created and executed successfully.


40

EX.NO : 9 a)
CREATION OF VIEW
DATE :
AIM

To create view with a large number of records using SQL.


PROCEDURE:

Step 1 : Start the program


Step 2 : Create table named as employees
Step 3: Insert the employees details into employees table.
Step 4 : Create the view named as v1 with select query.
Step 5: Display the desired output in neat format.
Step 6: Stop the program
QUERIES & OUTPUT:

RESULT:

Thus the view was created and executed successfully.


41

EX.NO : 9 b )
CREATION OF INDEX
DATE :

AIM

To create index for database tables with a large number of records using SQL.
PROCEDURE:

Step 1 : Start the program


Step 2 : Create table named as employees
Step 3: Insert the employees’ details into employees table.
Step 4 : Create the index named as idx_dob on date of birth of employees.
Step 5: Display the desired output in neat format.
Step 6: Stop the program

QUERIES & OUTPUT:

RESULT :

Thus the index was created and executed successfully.


42

EX.NO : 10
XML DATABASE
DATE :

AIM

To create an XML database and validate it using XML schema using SQL.
PROCEDURE:

Step 1 : Start the program


Step 2 : Create table named as xmldata_sample for employees.
Step 3: Insert the employees’ details into employees table.
Step 4 : Validate xmldata_sample data using XML schema.
Step 5: Display the desired output in neat format.
Step 6: Stop the program

QUERIES & OUTPUT:


43
44

RESULT:

Thus the XML database was created and validated using XML schema using SQL and
executed successfully.
45

EX.NO : 11
NOSQL DATABASE TOOLS
DATE :

AIM

To Create Document, column and graph based data using using


MongoDB,DynamoDB,Voldemort Key-Value Distributed Data store Hbase and Neo4j

NOSQL database tools

MongoDB use DATABASE_NAME is used to create database. The command will create a new
database if it doesn't exist, otherwise it will return the existing database.

Syntax

Basic syntax of use DATABASE statement is as follows -

use DATABASE_NAME

Example

If you want to use a database with name <mydb>, then use DATABASE statement would be as
follows -

>use mydb

switched to db mydb

To check your currently selected database, use the command db

>db
mydb

If you want to check your databases list, use the command show dbs.

>show dbs
local 0.78125GB
test 0.23012GB

Your created database (mydb) is not present in list. To display database, you need to insert at
least one document into it.

>db.movie.insert({"name":"tutorials point"})
>show dbs
local 0.78125GB
mydb 0.23012GB
test 0.23012GB

The dropDatabase() Method


46

MongoDB db.dropDatabase() command is used to drop a existing database.

Syntax
Basic syntax of dropDatabase() command is as follows -

db.dropDatabase()

This will delete the selected database. If you have not selected any database, then it will delete
default 'test' database.

Example

First, check the list of available databases by using the command, show dbs.

>show dbs
local 0.78125GB
mydb 0.23012GB
test 0.23012GB
>

if you want to delete new database <mydb>, then dropDatabase() command would be as
follows -

>use mydb
switched to db mydb
>db.dropDatabase()
>{ "dropped" : "mydb", "ok" : 1 }
>

Now check list of databases.

>show dbs
local 0.78125GB
test 0.23012GB
>

Traditional DB
In a traditional relational database management system (RDBMS), you have a table for
users and a table for updates. A foreign key represents the one-to-many relationship between
users and updates. Getting a user's updates is as simple as making a SQL query like "SELECT *
FROM updates WHERE updates.user_id = users.user_id". The problem with a traditional
RDBMS is that scaling becomes more difficult as you exceed the capabilities of the single
machine.

Simple secondary index that stores a list of element ids


index: user_id => [update_id]
updates: update_id => update_data
47

Secondary index paged by month


index: user_id, month => [update_id]
updates: update_id => update_data VStack underlying Voldemort stores
stack: user_id, page_id => update_id, next_page, previous_page
updates: update_id => update_data

// iterating over a VStack

VStack<Integer, String> myUpdates =

new VStack<Integer, String>(1337 /* example userid */,

storeClient /* Voldemort StoreClient */);

for (String update : myUpdates) {

System.out.println(update);

Select All Documents in a Collection

This operation uses a filter predicate of {}, which corresponds to the following SQL statement:

SELECT * FROM inventory

Specify Equality Condition

The following example selects from the inventory collection all documents where
the status equals "D":

This operation uses a filter predicate of { status: "D" }, which corresponds to the following SQL
statement:

SELECT * FROM inventory WHERE status = "D"

Specify Conditions Using Query Operators

The following example retrieves all documents from the inventory collection
where status equals either "A" or "D":

db.inventory.insertMany([

{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);
48

Specify Conditions Using Query Operators

A query filter document can use the query operators to specify conditions in the following form:

{ <field1>: { <operator1>: <value1> }, ... }

MongoDB Shell

The following example retrieves all documents from the inventory collection
where status equals either "A" or "D":

db.inventory.find( { status: { $in: [ "A", "D" ] } } )

The operation uses a filter predicate of { status: { $in: [ "A", "D" ] } }, which corresponds to the
following SQL statement:

SELECT * FROM inventory WHERE status in ("A", "D")

Refer to the Query and Projection Operators document for the complete list of MongoDB query
operators.

Specify AND Conditions

A compound query can specify conditions for more than one field in the collection's documents.
Implicitly, a logical AND conjunction connects the clauses of a compound query so that the
query selects the documents in the collection that match all the conditions.

The following example retrieves all documents in the inventory collection where
the status equals "A" and qty is less than ($lt) 30:

db.inventory.find( { status: "A", qty: { $lt: 30 } } )

MongoDB Shell

The operation uses a filter predicate of { status: "A", qty: { $lt: 30 } }, which corresponds to the
following SQL statement:

SELECT * FROM inventory WHERE status = "A" AND qty < 30


49

Specify OR Conditions

Using the $or operator, you can specify a compound query that joins each clause with a
logical OR conjunction so that the query selects the documents in the collection that match at
least one condition.

The following example retrieves all documents in the collection where


the status equals "A" or qty is less than ($lt) 30:

db.inventory.find( { $or: [ { status: "A" }, { qty: { $lt: 30 } } ] } )

MongoDB Shell

The operation uses a filter predicate of { $or: [ { status: 'A' }, { qty: { $lt: 30 } } ] }, which
corresponds to the following SQL statement:

SELECT * FROM inventory WHERE status = "A" OR qty < 30

RESULT:

Thus the Document, column and graph based data was created using
MongoDB,DynamoDB,Voldemort Key-Value Distributed Data store Hbase and Neo4j and was
done successfully.
50
Ex .No : 12 PAYROLL PROCESSING SYSTEM
Date :

AIM :
To create an application for payroll processing system using VB.NET and postgresSQL.

PROBLEM STATEMENT:

The payroll processing system is the systematic recording of all the transactions that take
place during the payroll transactions. Previously, all these details were entered manually. so it
was difficult to refer to all the transaction information later. In order to overcome these difficulties
a computerized form to record the transactions is necessary. Thus the banking system is designed
and implemented. The payroll processing system will interface with the employees’ details, all
type transactions, and maintain database.

PROCEDURE:

Step 1: Start the application


Step 2: Create the databases , appropriate tables for payroll processing system using
POSTGRES SQL.
Step 3: Design the payroll processing system entry form, calculation form and reports
using VB .NET in [Microsoft visual studio 2022]
Stepv4: Connect the database to payroll processing system
Step 5: Test the connectivity of database
Step 6: Enter data for payroll processing system
Step 7: Interface with the employees’ details, all type transactions, and maintain
database
Step 8: Display the data in reports in neat format.
Step 9: Stop the application.
51

Data base and table creation : employees

Creating TABLE: EMPLOYEES

INSERTING DATA INTO TABLE : EMPLOYEES

DISPLAY THE DATA FROM TABLE – EMPLOYEES :


52

Connecting database via ODBC connectivity

Download
postgres SQL
ODBC
DRIVERS
53

DESIGNING PAYROLL PROCESSING IN VB .NET USIN MICRO SOFT VISUAL


STUDIO
54

ADD DATA SOURCE TO PAYROLL PROCESSING:


55
56

Change all
fields into text
boxesand
Drag
employee’s
icon into form
design
57
58

FINALLY PAYROLL PROCESSING DEIGN:

TO VIEW CODE WINDOW :


59

AUTOMATICALLY CODE GENERATED:

Public Class Form1


Private Sub EmployeesBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles
EmployeesBindingNavigatorSaveItem.Click
Me.Validate()
Me.EmployeesBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.PostgresDataSet1)

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


'TODO: This line of code loads data into the 'PostgresDataSet1.employees' table. You can move, or remove it, as
needed.
Me.EmployeesTableAdapter.Fill(Me.PostgresDataSet1.employees)

End Sub
End Class

OUTPUT:

RESULT:

Thus the payroll processing system application was developed and incorporated the
database features and executed successfully.
60

EX.NO : 13 Database Design using ER Modeling, Normalization and


Implementation for Inventory Management for a EMart Grocery Shop
DATE :

AIM:
To design database using ER Modeling, Normalization and implement for
Inventory Management for a EMart Grocery Shop.

Sales Order

Fiction Company
202 N. Main
Mahattan, KS 66502

CustomerNumber: 1001 Sales Order Number: 405


Customer Name: ABC Company Sales Order Date: 2/1/2000
Customer Address: 100 Points Clerk Number: 210
Manhattan, KS 66502 Clerk Name: Martin Lawrence

Item Ordered Description Quantity Unit Price Total


800 widgit small 40 60.00 2,400.00
801 tingimajigger 20 20.00 400.00
805 thingibob 10 100.00 1,000.00

Order Total 3,800.00

First Normal Form Example


The new table is as follows:

SalesOrderNo, ItemNo, Description, Qty, UnitPrice

The repeating fields will be removed from the original data table, leaving the following.

SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName

These two tables are a database in first normal form

Second Normal Form Example


The new table will contain the following fields:

ItemNo, Description

All of these fields except the primary key will be removed from the original table. The primary
key will be left in the original table to allow linking of data:

SalesOrderNo, ItemNo, Qty, UnitPrice


61

Never treat price as dependent on item. Price may be different for different sales orders
(discounts, special customers, etc.)

Along with the unchanged table below, these tables make up a database in second normal form:

SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName

Third Normal Form Example


The new tables would be:

CustomerNo, CustomerName, CustomerAdd

ClerkNo, ClerkName

All of these fields except the primary key will be removed from the original table. The primary
key will be left in the original table to allow linking of data as follows:

SalesOrderNo, Date, CustomerNo, ClerkNo

Together with the unchanged tables below, these tables make up the database in third normal
form.

ItemNo, Description

SalesOrderNo, ItemNo, Qty, UnitPrice

Completed Tables in Third Normal Form


Customers: CustomerNo, CustomerName, CustomerAdd

Clerks: ClerkNo, ClerkName

Inventory Items: ItemNo, Description

Sales Orders: SalesOrderNo, Date, CustomerNo, ClerkNo

SalesOrderDetail: SalesOrderNo, ItemNo, Qty, UnitPrice


62

ER Diagram for the Sales order after Normalization:

RESULT:

Thus the Inventory Management for a EMart Grocery Shop database was designed using
ER Modeling, Normalization and was implemented for successfully.

You might also like