You are on page 1of 4

Subject Code: PUSDSBA502

Next Generation Database


B.Sc. Sem V
Time: 2 hours Total Marks: 50 marks

Note:
1. The candidate has option to either attempt question 3 or question 4.
2. Numbers to the right indicate full marks.
3. Use of approved scientific calculator is allowed.
4. Additional 20 minutes will be provided after the examination to submit the answers

Q1) 15 Marks

Q1A. Consider a collection name patients 5 Marks


{
_id:ObjectId(6547a3cf9023a33b),
first_name:’alpha’,
last_name:’James’,
age:16,
gender:’M’,
location:”kerla”,
dept:”ortho”
}
Where location can be ‘kerla’ ,’tamilnadu,’goa’,’karnatka’,
Gender can be “M”, “F”, “O”

1) Update the location to kerla for all ortho patients.


2) Add the new field bill_amount to all the documents
3) Change dept to ‘pedia’ for age below 12
4) Find the count of total documents in your collection
5)Display first name and age of all male patients.
Q1B Create a collection of your choice having only 2 simple documents (3 fields). 5 Marks
Demonstatre the difference between
.findOneAnd Replace() vs. .updateOne()
Q1C What are atomic operators in Mongodb. List them down with use. 5 Marks

Q2) What is significance of _id. 15 Marks


Write a query to assign ‘123’ to _id?
Can we have duplicate entries with same _id? Justify your answer
Q2A. Write queries to delete a document, a collection and a database 5 Marks
Q2B Write query to shrad a db.Expain Significance of shrad key. 5 Marks
Q2C db.orders.insertMany( [ 5 Marks
{ _id: 0, name: "Pepperoni", size: "small", price: 19,
quantity: 10, date: ISODate( "2021-03-13T08:14:30Z" ) },
{ _id: 1, name: "Pepperoni", size: "medium", price: 20,

Page 1 of 4
quantity: 20, date : ISODate( "2021-03-13T09:13:24Z" ) },
{ _id: 2, name: "Pepperoni", size: "large", price: 21,
quantity: 30, date : ISODate( "2021-03-17T09:22:12Z" ) },
{ _id: 3, name: "Cheese", size: "small", price: 12,
quantity: 15, date : ISODate( "2021-03-13T11:21:39.736Z" ) },
{ _id: 4, name: "Cheese", size: "medium", price: 13,
quantity:50, date : ISODate( "2022-01-12T21:23:13.331Z" ) }
])

Create orders collection as shown above.


Write a query that writern total sales of different pizzas in medium range.

Attempt Q3 OR Q4 15 Marks

Q3A. Create a database of movies. Create collection to accept only 100 enteries. 20 Marks
Also the collection should have fields, that compulsary have director name and
emailID, moviename cannot exceed 100 charecters.

Explain the syntax to add new data into collection. Add 10 enetries into the
collection . eg-
{
... "actor id":1,
... fname:"aamir",lname:"khan",
... address:[
... {street:"wall street"},
... {city:"new york"},
... {state:"mid state"},
... {country:"usa"},
... {pincode:"62201"}
... ],
... "contact details":[
... {emailid:"sallu@gmail.com"},
... {phonene:"12345678"}
... ]
... },
... {
... "actor id":2,
... fname:"aamir",lname:"khan",
... address:[
... {street:"wall street"},
... {city:"new york"},
... {state:"mid state"},
... {country:"usa"},
... {pincode:"62201"}
... ],
... "contact details":[

Page 2 of 4
... {emailid:"sallu@gmail.com"},
... {phonene:"12345678"}
... ]
... },

Write a querry to find all the releases made in Mumbai

Write a query that shows list of amir khan movies released in current year

Delete the film " 3 Idiots".

Write the aggregate query that groups the data based on actors, gives count of
movies, and sort them in an order.

Q4A. Create database EMP and Make Collection With name "EMPL" 20 Marks

Insert Records Into EMPL Collection


Eg-
db.empl.insert([
{no:1,name:"ST",salary:2000,role:"OB"},
{no:2,name:"MSD",salary:1500,role:"WK"},
{no:3,name:"YS",salary:1000,role:"ALR"},
{no:4,name:"RD",salary:1000,role:"MOB"},
{no:5,name:"RS",salary:500,role:"OB"},
{no:6,name:"BK",salary:500,role:"MOB"},
{no:7,name:"VK",salary:300,role:"BW"},
{no:8,name:"JB",salary:400,role:"BW"},
{no:9,name:"HP",salary:400,role:"ALR"},
{no:10,name:"VS",salary:300,role:"OB"}])
Display Data in Proper Format

Update Salary Of Employee where Name is "ST" by +8000

Update Salary Of All Employee by giving an increment of +4000 each

update role of "MSD" as "C and WK"

Add a New Field remark to document with name "RS" set Remark as WC

Add a New Field As Number 11,name AK,Salary 10000,role coch without


using insert statement. But for Doing So You should have a Record Added
woth number 11.

remove added New Field

Page 3 of 4
Update the Field "RD" by multiplying with salary by 2

To Find Document From the empl collection where name begins with S

Display Documents where in empl collection Field have OB,MOB

Display Documents where in empl collection Field have OB,MOB

Page 4 of 4

You might also like