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

20MIA1126 Lab2

The document outlines assignments for a NoSQL lab involving a student collection. It includes: 1) Creating a student collection with 3 documents containing name, registration number, marks, and address fields. 2) Updating student name and address fields for specific documents using queries and update operations. 3) Developing the student collection to include array and embedded document data types for elective subjects and subject marks. 4) Performing update operations on the complex student documents like updating marks for a specific student ID, replacing subject names, and replacing a subject for all students.

Uploaded by

Varun Vaishnav
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 views10 pages

20MIA1126 Lab2

The document outlines assignments for a NoSQL lab involving a student collection. It includes: 1) Creating a student collection with 3 documents containing name, registration number, marks, and address fields. 2) Updating student name and address fields for specific documents using queries and update operations. 3) Developing the student collection to include array and embedded document data types for elective subjects and subject marks. 4) Performing update operations on the complex student documents like updating marks for a specific student ID, replacing subject names, and replacing a subject for all students.

Uploaded by

Varun Vaishnav
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/ 10

Name: Chenchu Aravind

Reg No: 20MIA1126

NOSQL lab Assignment-2


1.Develop a student collection with primitive data types student name, register
number cat1 mark of nosql and address with minimum 3 documents

db.MIA1126.insertMany([

"name": "Chenchu",

"registerNumber": "1126",

"NoSQL cat1 marks": 85,

"address":"Thazambur chennai"

},

"name": "Aravind",

"registerNumber": "1127",

"NoSQL cat1 marks": 92,

"address": "Perungudi Chennai"

},

"name": "Pavani",

"registerNumber": "1128",

"NoSQL cat1 marks": 78,

"address": "SRP tools Chennai"

]);
2.Update the student name for the given registration number

db.MIA1126.updateOne(

{ "registerNumber": "1127" },
{ $set: { "name": "Rahul" } }

);

Update the address for the given name and show the upsert option with explanation
db.MIA1126.updateOne(

{ "name": "Rahul" },

{ $set: { "address":"Guindy Chennai" } },

{ upsert: true }

);
The upsert option is set to true, which means that if a document with the given
name ("Rahul") doesn't exist, a new document will be inserted with the specified
address (" Guindy Chennai”).

Update the mark of the students for the given name with multi property and provide
suitable explanations

db.MIA1126.updateOne(

{ "name": "Chenchu" },

{ $set: { "NOSQL cat1 marks": 95 } }

);
2. Develop a student collection with appropriate complex data types - use array to
store the list of elective subjects and embedded document to store the
subject_name:mark of the subject. Initialize the collection with minimum 3 documents

db.MIA1126.insertMany([

"name": "Chenchu",

"studentId": "1126",

"electiveSubjects": ["Math", "Science", "History"],

"subjectMarks": {
"Math": 90,

"Science": 85,

"History": 78

},

"name": "Aravind",

"studentId": "1127",

"electiveSubjects": ["Science", "English", "Art"],

"subjectMarks": {

"Science": 92,

"English": 88,

"Art": 75

},

"name": "rahul",

"studentId": "1128",

"electiveSubjects": ["History", "Math", "AI"],

"subjectMarks": {

"History": 80,

"Math": 88,

"AI": 95

]);
Update the mark of a particular student for a particular course for a given student id.

db.MIA1126.updateOne(

{ "studentId": "1126" },

{ $set: { "subjectMarks.Science": 95 } }

);
Replace the subject names with “TOC” for a given student name “X”

db.MIA1126.updateOne(

{ "name": "Chenchu" },

{ $set: { "electiveSubjects": ["TOC", "TOC", "TOC"] } }

);
Replace the subject “X” with “Y” for example (“Science” with “EVS”) for all the
students.

db.MIA1126.updateMany(

{ "electiveSubjects": "History" },

{ $set: { "electiveSubjects.$": "Polity" } }

);

You might also like