tangoclinh1995 / thehonorclub-mobileapp

The Honor Club's Mobile App Project for COMP 3111H
2 stars 1 forks source link

[Discussion] Structure of the Firebase Database #1

Open tangoclinh1995 opened 7 years ago

tangoclinh1995 commented 7 years ago

I propose the structure of our Firebase Database as following:

{
    "event": {
        [event_auto_generated_uid]: {
            "name": ,
            "description": [Short description],
            "email": [Email of contact person],
            "location": [Where event happens],

            "timestamp_begin": [UNIX Timestamp],
            "timestamp_end": [UNIX Timestamp],

            "min_member_per_team": [Number],
            "max_member_per_team": [Number]
        },
        ...
    },

    "user_have_team": {
        [event_uid]: {
            [user_uid]: 1,
            ...
        },
        ...        
    },

    "team": {
        [team_auto_generated_uid]: {
            "event_uid": [This helps refer to event this team belongs to],

            "name": ,
            "description": [Short description],

            "skills_needed": {
                [skill_tag]: [Number of people in team who have this skill],
                ...
            },

            "positions_needed": {
                [position]: [Number of people in team who can be at this position],
                ...
            },

            "leader_uid": [User UID of Leader],
            "members_uid": {
                [member_uid]: 1
                ...
            },

            "current_size": [Current size of the team, = 1 + Size of members_uid array],
            "can_add_more": [Number of people the team is willing to accept more, = Event's Max Number of Member Per Team - current_size]            
        },
        ...
    }

    "jointeam_request": {
        [uid = from_user_uid + " => " + to_team_uid]: {
            "from_user_uid": [UID of user who wants to join a team],
            "to_team_uid": [UID of target team],
            "event_uid": [UID of event that hosts this request]
        },
        ...
    },

    "invitemember_request": {
        [uid = from_team_uid + " => " + to_member_uid]: {
            "from_team_uid": [UID of user who is invited to join a team],
            "to_member_uid": [UID of target user],
            "event_uid": [UID of event that hosts this request]
        },
        ...        
    }

    "user_info": {
        [user_auto_generated_uid]: {
            "name": [User name],
            "photoURL": [User photo URL],
            "email": [User email],
            "bio": [A short introduction],

            "skills": [An array of string],
            "desired_positions": [An array of string],

            "leader_of": {
                [team_uid_where_user_is_leader]: 1,
                ...
            },
            "member_of": {
                [team_uid_where_user_is_member]: 1,
                ...
            }
        },
        ...
    }

}

Feel free to COMMENT BELOW to propose your adjustment

jshin49 commented 7 years ago

This structure looks great!

Nice work!

If you have any DB already created, can you share it on slack perhaps?

tangoclinh1995 commented 7 years ago

Actually I design the code such that anyone can hook up his/her own Firebase Database to the project and test independently with each other (Please refer to README)

For testing, after trying to write test for the Profile Page Controller (please refer to my Pull Request), I found that we do not need connecting to the real database at all to do testing :joy:

The key here is to use Jasmine Spy.

jshin49 commented 7 years ago

well, its always a pain to create a db, so i was wondering if you had some dummy data db already created.

It would be nice if you can simply export that DB to a .json file and we can simply import it as .json on Firebase.

That way we'd be able to test with same data.

tangoclinh1995 commented 7 years ago

Sorry, my database is still empty now, as I found that I do not need database to do testing :joy:

But just wonder: do you know how to add permission for others to access my Firebase database?

jshin49 commented 7 years ago

Yes I have experience in doing that, so once we have a populated database, we can start sharing it, because it's waste of time to test every component with an individual database

tangoclinh1995 commented 7 years ago

Hi @hpsuenaa @sleeplessclassics @jennykang @juked060, I made some big changes to the database structure which might affect your code.

Please take a look and comment whether the degree of impact on your code. Feel free to ask question about the database structure here 😄

List of changes in database structure:

cameronsuen commented 7 years ago

For the skills_needed field in team node, is it the number of people in the team currently who have the skill, or the number of people who need to have the skill, I think those two are different and should be separated?

tangoclinh1995 commented 7 years ago

@hpsuenaa It is the number of people in the team currently who have the skill.

This is used for recommendation algorithm. It will recommend people who has the skill are currently possessed by the least number of people in the team

tangoclinh1995 commented 7 years ago

@hpsuenaa skills_needed is similar to positions_needed as well. So, I think there will be no position called leader in positions_needed

cameronsuen commented 7 years ago

Thanks for the reply, but how about the balance of skill sets in a team? Should this be included somewhere during team formation?

tangoclinh1995 commented 7 years ago

What do you mean by including somewhere during team formation? Do you mean during the swiping time (when team leader is searching for a member, and vice versa)

cameronsuen commented 7 years ago

I mean, should a team leader be able to specify the number of people he wants who possess a certain skill?

tangoclinh1995 commented 7 years ago

Ah, I see. It's a good improvement for Milestone 3.

Right now, how about only considering the kind of skills needed?

cameronsuen commented 7 years ago

Ok sure, thanks a lot! Will create a separate issue afterwards

jshin49 commented 7 years ago

@tangoclinh1995 This structure needs change in the user_info section.

I realized that when I user sign outs, and signs in again, his/her auto_generated_uid will change.

Hence we need to create the DB based on his/her Facebook UID.

jshin49 commented 7 years ago

For the following parts, we need modification:

From this:

    "jointeam_request": {
        [jointeam_request_auto_generated_uid]: {
            "from_user_uid": [UID of user who wants to join a team],
            "to_team_uid": [UID of target team],
            "event_uid": [UID of event that hosts this request]
        },
        ...
    },

    "invitemember_request": {
        [invitemember_request_auto_generated_uid]: {
            "from_team_uid": [UID of user who is invited to join a team],
            "to_member_uid": [UID of target user],
            "event_uid": [UID of event that hosts this request]
        },
        ...        
    }

    "user_info": {
        [user_auto_generated_uid]: {
            "name": [User name],
            "photoURL": [User photo URL],
            "email": [User email],
            "bio": [A short introduction],

            "skills": [An array of string],
            "desired_positions": [An array of string],

            "leader_of": {
                [team_uid_where_user_is_leader]: 1,
                ...
            },
            "member_of": {
                [team_uid_where_user_is_member]: 1,
                ...
            }
        },
        ...

To This:

    "jointeam_request": {
        [from_user_uid]: {
            "[UID of target team1]": "[UID of event that hosts this request]",
            "[UID of target team2]": "[UID of event that hosts this request]",
            ...
        },
        ...
    },

    "invitemember_request": {
        [from_team_uid]: {
            "[UID of target user1]": "[UID of event that hosts this request]",
            "[UID of target user2]": "[UID of event that hosts this request]",
        },
        ...        
    }

    "user_info": {
        [user_fb_id]: {
            "name": [User name],
            "photoURL": [User photo URL],
            "email": [User email],
            "bio": [A short introduction],

            "skills": [An array of string],
            "desired_positions": [An array of string],

            "leader_of": [
                [team_uid_where_user_is_leader],
                [team_uid_where_user_is_leader],
                [team_uid_where_user_is_leader],
                ...
            ],
            "member_of": [
                [team_uid_where_user_is_member],
                [team_uid_where_user_is_member],
                [team_uid_where_user_is_member],
                ...
            ]
        },
        ...

I removed the autogenerated UID part, because with this, it would be hard to search and match.

tangoclinh1995 commented 7 years ago

@jshin49 The structure you propose cannot work when team sends multiple request to multiple users. The same for member sendings multiple request to multiple team.

By the way, I changed the definition of jointeam_request UID and invitemember_request UID when I developed the matchingRequestService. I've just updated the first post here, you can take a look. Sorry I didn't inform you about that.