Professional Documents
Culture Documents
Lab Report
Cloud Computing
Submitted by Submitted to
Name:
Program: BSc.CSIT
Roll no:
Batch: 2074
Semester:
Date:
Kathmandu, Nepal
2022
Q. Create an Extended Entity Relationship framework for the following:
- a user will be able to see a list of restaurants nearby, see the menu and place an order.
- the restaurants will be able to login/signup and add/edit list of menu, give discounts up to
30%.
EER diagram:
Q. Convert the Extended Entity Relationship diagram from lab 1 to relational schema.
);
dbuser( id, name (firstName, middleName, lastName), phone, address (country, state, city))
Then insert self-information and 5 other entries, and select record with country as ‘Nepal’.
1. Create table:
"firstName" text,
"middleName" text,
"lastName" text
);
"country" text,
"state" text,
"city" text
);
"name" nameFormat,
);
Output:
Output:
FROM products
GROUP by productLine
Output:
Q4. How many orders on each productline?
FROM orderdetails
ON orderdetails.productCode=products.productCode
GROUP BY products.productLine;
Output:
FROM products
GROUP by productLine
Output:
FROM orderdetails
ON orderdetails.productCode=products.productCode
ON orders.orderNumber=orderdetails.orderNumber
WHERE orders.status="Shipped"
GROUP BY products.productLine;
Output:
Setting up replication in MySQL
MySQL replication is a process that allows data to be copied/replicated from one server to the other at the
same time. It is mainly done to increase the availability of data. One of the main reasons that people go
for MySQL master-slave replication is for data recovery.
For setting up the master-slave in MySQL, let us assume that server (192.168.0.31) is to be our master
and (192.168.0.34) the slave.
Step 1: Edit the configuration files & start the MySQL Servers
The first step in setting up replication involves editing the “my.cnf” file on the servers that will serve as
the master and slave. We will provide local configuration files “master.cnf” and “slave.cnf” that will be
used when starting up the MySQL servers.
master.cnf:
[mysqld]
server-id=1
log-bin=black-bin.log
datadir=/home/billy/mysql/master/data
innodb_flush_log_at_trx_commit=1
sync_binlog=1
slave.cnf:
[mysqld]
server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
datadir=/home/billy/mysql/slave/data
After setting up the configuration files, we will start MySQL server using the following command for
both master and slave system.
master-server> mysqld --defaults-file=<location of master.cnf> &
Creating an account on the master server that the slave server can use to connect. his account must be
given the REPLICATION SLAVE privilege.
-> MASTER_USER='replication_user',
-> MASTER_PASSWORD='password’,
-> MASTER_LOG_FILE='',
-> MASTER_LOG_POS=4;
where,
We can perform basic checks by creating a database and table in master server, then verify that table in
slave server.
Master-server:
master> create table adbms.tb1 (id int not null primary key);
Slave-server:
Read Operations
Read operations retrieve documents from a collection; i.e. query a collection for documents.
MongoDB provides the following methods to read documents from a collection:
● db.<collection>.find(<criteria>)
We can specify query filters or criteria that identify the documents to return.
For example,
db.users.find(
{
name: “jack”
}
)
Update Operations
Update operations modify existing documents in a collection. MongoDB provides the following
methods to update documents of a collection:
● db.<collection>.updateOne(<filter>, <update>)
● db.<collection>.updateMany(<filter>, <update>)
● db.<collection>.replaceOne(<filter>, <replacement>)
In MongoDB, update operations target a single collection. All write operations in MongoDB are
atomic on the level of a single document. We can specify criteria, or filters, that identify the
documents to update. These filters use the same syntax as read operations.
For example,
db.users.updateMany(
{
name: “jack”
},
{j
$set:{ email: “jack@gmail.com” }
}
)
Delete Operations
Delete operations remove documents from a collection. MongoDB provides the following
methods to delete documents of a collection:
● db.<collection>.deleteOne(<filter>)
● db.<collection>.deleteMany(<filter>)
In MongoDB, delete operations target a single collection. All write operations in MongoDB are
atomic on the level of a single document. We can specify criteria, or filters, that identify the
documents to remove. These filters use the same syntax as read operations.
For example,
db.users.deleteMany(
{
name: “jack”
}
)
Aggregation Pipelines
Aggregation pipeline is the method of processing a group of documents in one or more stages,
where each stage performs distinct operations. Each stage passes the output to the next stage.
Aggregation pipeline is achieved by using the following methods:
● db.collection.aggregate()
● aggregate
Aggregation steps:
1. Download Mongosh from the Atlas website to connect to the database.
2. Whitelist current IP address.