Click here to Skip to main content
15,346,965 members
Home / Discussions / Database
   

Database

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 3:10
cofounderChris Maunder16-Jul-09 3:10 
PinnedHow to get an answer to your question PinPopular
Chris Maunder10-Nov-05 16:30
cofounderChris Maunder10-Nov-05 16:30 
QuestionPivot works, but spread column values not as expected Pin
#realJSOP19-Jun-22 1:58
mva#realJSOP19-Jun-22 1:58 
AnswerRe: Pivot works, but spread column values not as expected Pin
Richard Deeming19-Jun-22 21:52
mveRichard Deeming19-Jun-22 21:52 
GeneralRe: Pivot works, but spread column values not as expected Pin
#realJSOP19-Jun-22 22:20
mva#realJSOP19-Jun-22 22:20 
GeneralRe: Pivot works, but spread column values not as expected Pin
Richard Deeming19-Jun-22 22:36
mveRichard Deeming19-Jun-22 22:36 
GeneralRe: Pivot works, but spread column values not as expected Pin
#realJSOP19-Jun-22 23:19
mva#realJSOP19-Jun-22 23:19 
QuestionDatabase design for a project Pin
Gopika Ravikumar16-Jun-22 6:35
MemberGopika Ravikumar16-Jun-22 6:35 
AnswerRe: Database design for a project Pin
Craig Robbins16-Jun-22 7:31
MemberCraig Robbins16-Jun-22 7:31 
AnswerRe: Database design for a project Pin
Mycroft Holmes16-Jun-22 12:44
professionalMycroft Holmes16-Jun-22 12:44 
QuestionHow to get this result in oracle database? Pin
HowardCheng22-May-22 4:58
professionalHowardCheng22-May-22 4:58 
AnswerRe: How to get this result in oracle database? Pin
Mycroft Holmes22-May-22 13:18
professionalMycroft Holmes22-May-22 13:18 
QuestionSQL SERVER STORE PROCEDURE Pin
Luis M. Rojas28-Apr-22 3:45
MemberLuis M. Rojas28-Apr-22 3:45 
AnswerRe: SQL SERVER STORE PROCEDURE Pin
Richard Deeming28-Apr-22 4:34
mveRichard Deeming28-Apr-22 4:34 
AnswerRe: SQL SERVER STORE PROCEDURE Pin
Mycroft Holmes28-Apr-22 11:59
professionalMycroft Holmes28-Apr-22 11:59 
GeneralRe: SQL SERVER STORE PROCEDURE Pin
jschell8-May-22 8:07
Memberjschell8-May-22 8:07 
QuestionGiven two dates, count the number of dates in the range that is within month X Pin
Jame_T13-Apr-22 3:43
MemberJame_T13-Apr-22 3:43 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
Craig Robbins13-Apr-22 4:10
MemberCraig Robbins13-Apr-22 4:10 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
CHill6020-Apr-22 7:04
mveCHill6020-Apr-22 7:04 
QuestionBest practice for creating a limited access ms-sql user ? Pin
David Mujica12-Apr-22 11:12
MemberDavid Mujica12-Apr-22 11:12 
AnswerRe: Best practice for creating a limited access ms-sql user ? Pin
jschell8-May-22 8:11
Memberjschell8-May-22 8:11 
QuestionMysql How to sort row ORDER BY another query? Pin
Zac Ang3-Apr-22 10:45
MemberZac Ang3-Apr-22 10:45 
SuggestionRe: Mysql How to sort row ORDER BY another query? Pin
Richard Deeming3-Apr-22 21:46
mveRichard Deeming3-Apr-22 21:46 
AnswerRe: Mysql How to sort row ORDER BY another query? Pin
CHill606-Apr-22 2:57
mveCHill606-Apr-22 2:57 
QuestionFilter data before lookup(join) two collections in mongodb Pin
85510-Mar-22 4:20
Member85510-Mar-22 4:20 
I'm writing a function which will join two collections and two filters for each.
C#
public class Teacher
{
        public string Id{ get; set; }
        public string Name{ get; set; }
        public string TeacherFilter{ get; set; }
        ...
}

public class Student
{
        public string Id{ get; set; }
        public string Name{ get; set; }
        public string StudentFilter{ get; set; }
        public string TeacherId{ get; set; }
        ...
}

public class TeacherStudents
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        public IEnumerable<Student> Students{get;set;}
}

public class TeacherStudents
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        public IEnumerable<Student> Student{get;set;}
}

public class TeacherStudent
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        ...
        public Student Student{get;set;}
}

Get(string TeacherFilter,string StudentFilter).


Here is how i implement it
var query = teacherCollection.Aggregate().Match(x => x.TeacherFilter== TeacherFilter); //filter teach
var query1 = query
.Lookup<Teacher, Student, TeacherStudent>(studentCollection, t => t.Id, s => s.TeacherId, l => l.Student)
.Unwind(x => x.Student, new AggregateUnwindOptions<TeacherStudent>())
.Match(x => x.StudentFilter== StudentFilter) //filter student   

For the teacher collection, useless data has been filter out which will reduce the data size when doing the lookup(join). But for the student collection, the match stage is appended after the lookup. so does all the data from student will join with teacher behind the scenes? is it possible to filter out some student data before the lookup?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.