I am fairly new in the firebase/backend world. I have started learning recently. So I have decided to make a sample project to learn. The project is more like job profile such as LinkedIn/Smartr. I am struggling to make a decision how I should structure my database.
I am using Angular 13 in frontend and Firebase(@angular/fire) as backend.
So the project I am trying to build is a very simple. It will have some basic info of a user such as firstName
, lastName
, age
, title
, location
. These are the basic information which will be necessary to complete a profile.
So in Firestore I have made a collection called Users where for each user have a document id that is generated with the following information.
{
age: 23,
email: "demo.user@mail.com",
firstName: "Demo",
lastName: "User",
title: "Engineer"
location: "USA"
uid: "232dsf23"
}
The system will also have a authentication system. Using the already defined firebase authentication system.
So the uid
I am keeping is the id
I am getting in response after a user is signed up. I am using that as the Users
Document Id.
So far I have done this. So the next thing I want to add in my demo project is the a Work Experience section.
The functionality will work exactly like we see in LinkedIn/Smartr. A user can only add/edit only one work experience at a time using a modal/dialog.
So my queries are:
Should I include
workExperience
a new object property in each document ofusers
collection. If I keep a new property calledworkExperience
in the documents ofusers
collection then I am going to need an id with each experience if i am not wrong because a user can edit/update only one experience at a time. So since firebase doesn't support auto incremental id (as far as I read) then how should I approach it?If I make a separate collection called
work-experience
where adding a new experience will create a new document in that collection for every user then how would I connect that which experience is related to which user? And how should I query to get the expected data.
Which procedure should I follow? If you any have other suggestion how I should approach it please suggest.