In my application, a user can choose between 3 profiles to created.
For now, I have 3 tables in the database representing the profiles. One table for each profile.
But I don't know how to work with this In a proper way In the code.
Let say that I visit a profile by entering the following URL:
mysite.com/fishness
Either to get data from the database that belongs to the "fishness" profile, I must search In three tables. How should I do the search? Should I just do three querys for each table? Or Is It a nicer way to do this?
Another thing Is when the user logs In. How should I get the profile that belongs to the user who logs in?
Should I have navigation properties In my AppUser
model( the model for the user )?
The ugly thing In my opinion about this, Is that I must then add navigation
properties for all three profiles In my AppUser
.
Can anyone give me tips about how to design this?
Here Is my three profile tables:
Profile1:
Id
UserId (the users Id)
Name
CoverPicture
Description
WelcomePage
Profile2:
Id
UserId (the users Id)
Name
CoverPicture
Description
WelcomePage
Profile3:
Id
UserId
Firstname
Lastname
Birth
Profilepicture
WelcomePage
You design is not good because it is not scallable , imagine you want to create a new profile , you will be obliged to create new table and edit your code .
My suggestion is to create a table profile
and user
, user has a column profileId that reference profile column id (foreign key) .
Table profile
ProfileID
ProfileDesignation
Table user
UserId
Firstname
Lastname
Birth
Profilepicture
CoverPicture
Description
WelcomePage
ProfileID references profile.ProfileID