diff --git a/Practical/Assignment-B2/Queries-B2.md b/Practical/Assignment-B2/Queries-B2.md index 7e2995a..9c630ea 100755 --- a/Practical/Assignment-B2/Queries-B2.md +++ b/Practical/Assignment-B2/Queries-B2.md @@ -1,6 +1,10 @@ -## Queries +## Queries-B2 -### A +### Group A + +> ![NOTE] +> Use Employee database created in Assignment B-01 and perform following aggregation operation +> Refer [Queries-B1](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Practical/Assignment-B1/Queries-B1.md) 1. Return Designation with Total Salary Above 200000: ```mongodb @@ -17,6 +21,7 @@ db.Employee.aggregate([ } } ]) + ``` 2. Find Employee with Total Salary for Each City with Designation "DBA": @@ -32,6 +37,7 @@ db.Employee.aggregate([ } } ]) + ``` 3. Find Total Salary of Employee with Designation "DBA" for Each Company: @@ -47,6 +53,7 @@ db.Employee.aggregate([ } } ]) + ``` 4. Returns Names and _id in Upper Case and in Alphabetical Order: @@ -62,11 +69,13 @@ db.Employee.aggregate([ $sort: { Name: 1 } } ]) + ``` 5. Count All Records from Collection: ```mongodb db.Employee.countDocuments() + ``` 6. For Each Unique Designation, Find Avg Salary and Output Sorted by AvgSal: @@ -82,6 +91,7 @@ db.Employee.aggregate([ $sort: { AvgSalary: 1 } } ]) + ``` 7. Return Separate Value in the Expertise Array Where Name of Employee is "Swapnil": @@ -97,6 +107,7 @@ db.Employee.aggregate([ $project: { Expertise: 1 } } ]) + ``` 8. Return Separate Value in the Expertise Array and Return Sum of Each Element of Array: @@ -112,6 +123,7 @@ db.Employee.aggregate([ } } ]) + ``` 9. Return Array for Designation Whose Address is "Pune": @@ -124,6 +136,7 @@ db.Employee.aggregate([ $project: { Designation: 1 } } ]) + ``` 10. Return Max and Min Salary for Each Company: @@ -137,41 +150,54 @@ db.Employee.aggregate([ } } ]) + ``` -### B +### Group B + +> ![NOTE] +> Use Employee database created in Assignment B-01 and perform following aggregation operation +> Refer [Queries-B1](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Practical/Assignment-B1/Queries-B1.md) + 1. Create Single Field Indexes on Designation: ```mongodb db.Employee.createIndex({ Designation: 1 }) + ``` 2. Create Compound Indexes on Name and Age: ```mongodb db.Employee.createIndex({ "Name.FName": 1, Age: -1 }) + ``` 3. Create Multikey Indexes on Expertise Array: ```mongodb db.Employee.createIndex({ Expertise: 1 }) + ``` 4. Return a List of All Indexes on Collection: ```mongodb db.Employee.getIndexes() + ``` 5. Rebuild Indexes: ```mongodb db.Employee.reIndex() + ``` 6. Drop Index on Remove Specific Index: ```mongodb -db.Employee.dropIndex("empIndex") +db.Employee.dropIndex("empIndex") + ``` 7. Remove All Indexes Except for the _id Index from a Collection: ```mongodb db.Employee.dropIndexes() + ```