Skip to content

db Modeling and db related discussion. #42

@asiyani

Description

@asiyani

There are few topics we need to discuss regarding the database.

// Schema for logged in users.
userSchema = new Schema({
   _id: mongoose.Schema.Types.ObjectId,
    githubId: Number,
    login: String,
    name: String,
    html_url: String,
    accessToken: String,
});
// Schema of usernames of stargazers in Github
usernameSchema = new Schema({
    _id: mongoose.Schema.Types.ObjectId,
    githubId: Number,
    login: String,
    name: String,
    html_url: String,
    location: String,
    bio: String,
    public_repos: Number,
    public_gists: Number,
    followers: Number,
    dbLastUpdated: Date,
    starredIds: [mongoose.Schema.Types.ObjectId],
});
repositorySchema = new Schema({
    _id: mongoose.Schema.Types.ObjectId,
    name: String,
    html_url: String,
    description: String,
    stargazers_count: Number,
    forks_count: Number,
    created_at: Date,
    updated_at: Date,
    language: String,
});
****Questions****
1. is properties of each schema is enough or do we need to store more data related to each collection.
2. relationship between username and repository Schema? Embedded, one-to-N or N-to-N?
3. DB server for development -  local mongo OR mlab?

I think

  1. userSchema & repositorySchema is fine but usernameSchema got lots of stuff which we might not need. like location, bio

  2. This one depends on the query we will be running on DB and amount of data. If I am right at the moment we are querying usernames to get repository. in that case......

usernameSchema = new Schema({
    _id: 
    name: 
    :
    repositoryIDs: [ObjectId1,ObjectId2,......N],
});

Problem with this is some username like 'tj' got 1.7k starred repositories! thats to many Ids to put in array.
Other solution.
because we have limited number of usernames we can do this....

repositorySchema = new Schema({
    _id: 
    name: 
    :
    usernameIDs: [ObjectId1,ObjectId2,......N],
});

Problem is it will be dificult to just query repository based on usernames..
Don't know 😖

  1. local DB requires initial setup, mlab needs creating account and MAX limit is 0.5GB (I think this should be more than enough 😉 ). I personally prefer local DB server for developing.

Lets discuss answers for all 3 questions or any other questions related to DB.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions