Answer the question
In order to leave comments, you need to log in
Database design. Links between profiles?
Hello.
Database design question. How would you design the databases in the example below and organize the communication between them.
There is a profile of the Hairdresser and the Client. As I understand it, a USERS table is created where authorization data is stored (id, login, email, password, usergroup) and there are 2 profiles, they have only one thing in common (avatar, and full name).
Hairdresser Profile: stores data (full name, profile picture, city of residence [separate table in cities by one-to-many connection], haircuts [separate table with haircut names], prices, contacts [separate table with contacts {landline phone, mobile phone, skype and td}], about yourself, portfolio [separate table with photos], testimonials [separate table with reviews for each hairdresser]) and link to the appointment table (date, time and place).
Client profile : stores full name and avatar data and a connection with the hairdresser's preliminary reservation table for a specific date and time.
Interested in how to be with profiles? How would you design this relationship in this situation? Would you create 2 profile tables, one for the client and one for the hairdresser, and keep your data for each, or would you combine everything into one?
One more thing about expansion. For example, if in the future you add a make-up artist and, as I assume, he will have his own profile with his information.
How to competently and correctly design this task and link the user table with the profiles of the client and the hairdresser or makeup artist?
Answer the question
In order to leave comments, you need to log in
Why can't a client be a hairdresser? Therefore, a separate table of people profiles is required. (name, addresses, avatars)
And then a table of hairdressers in which there is a link to a person, and then the specific data of a hairdresser.
One table, the difference is not significant, there will be a couple of empty fields and that's it.
Even more confused. So one table of profiles to do or 2?
Option one :
Users:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`username` varchar(255) NOT NULL COMMENT 'Имя пользователя',
`email` varchar(255) NOT NULL COMMENT 'Электропочта',
`password` varchar(255) NOT NULL COMMENT 'Пароль',
PRIMARY KEY (`id`)
)
CREATE TABLE `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`name` varchar(255) NOT NULL COMMENT 'Имя группы пользователей',
PRIMARY KEY (`id`)
)
CREATE TABLE `usergroups` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`user_id` int(11) NOT NULL COMMENT 'ID пользователя',
`group_id` int(11) NOT NULL COMMENT 'ID группы пользователей',
PRIMARY KEY (`id`)
)
CREATE TABLE `profile` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`avatar` varchar(255) NOT NULL COMMENT 'Аватарка',
`firstname` varchar(255) NOT NULL COMMENT 'Имя пользователя',
`lastname` varchar(255) NOT NULL COMMENT 'Фамилия пользователя',
`about` text COMMENT 'О себе',
`location_id` int(11) NOT NULL COMMENT 'Индификатор города',
`haircut_id` int(11) NOT NULL COMMENT 'Индификатор стрижки',
`price` decimal(10,2) NOT NULL COMMENT 'Индификатор стрижки',
`contacts_id` int(11) NOT NULL COMMENT 'Индификатор контакта',
`portfolio_id` int(11) NOT NULL COMMENT 'Индификатор портфолио',
`reviews_id` int(11) NOT NULL COMMENT 'Индификатор отзыва',
PRIMARY KEY (`id`)
)
CREATE TABLE `profile_hairdresser` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`user_id` int(11) NOT NULL COMMENT 'Номер записи',
`avatar` varchar(255) NOT NULL COMMENT 'Аватарка',
`firstname` varchar(255) NOT NULL COMMENT 'Имя пользователя',
`lastname` varchar(255) NOT NULL COMMENT 'Фамилия пользователя',
`about` text COMMENT 'О себе',
`location_id` int(11) NOT NULL COMMENT 'Индификатор города',
`haircut_id` int(11) NOT NULL COMMENT 'Индификатор стрижки',
`price` decimal(10,2) NOT NULL COMMENT 'Индификатор стрижки',
`contacts_id` int(11) NOT NULL COMMENT 'Индификатор контакта',
`portfolio_id` int(11) NOT NULL COMMENT 'Индификатор портфолио',
`reviews_id` int(11) NOT NULL COMMENT 'Индификатор отзыва',
PRIMARY KEY (`id`)
)
CREATE TABLE `profile_client` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`user_id` int(11) NOT NULL COMMENT 'Номер записи',
`avatar` varchar(255) NOT NULL COMMENT 'Аватарка',
`firstname` varchar(255) NOT NULL COMMENT 'Имя пользователя',
`lastname` varchar(255) NOT NULL COMMENT 'Фамилия пользователя',
PRIMARY KEY (`id`)
)
CREATE TABLE `profile_client_hairdresser` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Номер записи',
`user_id` int(11) NOT NULL COMMENT 'ID пользователя',
`profile_id` int(11) NOT NULL COMMENT 'ID профиля пользователей',
PRIMARY KEY (`id`)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question