S
S
Sergei Sobyanin2017-07-15 21:55:28
MySQL
Sergei Sobyanin, 2017-07-15 21:55:28

How to design a database in this case?

We were given the task to introduce authentication on the site through social networks.
And everything would be fine, but I can not figure out the competent design of the database. Of course, I could code like a pimply fifth grader, but I write in Laravel, which means I need to do everything perfectly)
So, I have a User model. There is a users table. Here we store the name, ID, link to the profile picture, etc. To add the ability to link social accounts to ours, I plan to create a Connection model and a connections table with the following structure - id, user_id, service_id, uid (uid is a unique user ID in the connected social network). Also, I will create a Service model with a services table with the following structure - id, name. Here we will store a list of supported social networks (one might say, a reference table).
It seems to be normal, but not too intricate? Are there any shorter solutions to this problem? I would be very grateful!
UPD: I see a lot of such questions were asked on the Toaster recently, the cases are very similar, but the info is not exhaustive for me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2017-07-15
@mossobyanin

It seems to be normal, but not too intricate?

Hmm
tricky? Is it? Perhaps, the link to the avatar could be taken out in general, but to make a file table, and assign the user a foreign key avatar_id, which will refer to the file table entry. Technical profile information of a token type can be separated from information about a person (such as interests, profession, date of birth). Etc.
There is no limit to complexity. But there is a specific issue. Now it will be too obvious a phrase: if within the framework of this task and your vision of the project you don’t need to complicate it, you don’t need to complicate it. If you need it, you need it.
Make decisions yourself if you are alone, and consult with the team if you are in a team. All other tips for developing and designing your application \ base \ api \ ..., which begin with the words "isn't it too complicated ...", are known only to you and your team. On such resources, there are many specialists of different levels who will come running and advise you on your application a bunch of things, but it’s not a fact that their options will be better.
For example: I think that your solution is quite appropriate, yes, models and tables should be separated as you indicated, and a shorter solution is simply not required. But this is my opinion, there may be many others. I don’t see how your project is developing, what goals it has and at what stage it is, in order to somehow argue my words according to your situation in the project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question