Type of relationship between tables (Laravel)

2

I'm implementing my CBT, about photos and such .. But now I got a doubt in the time to create the tables ... I'm using Laravel okay?

Next, I have the following tables:

users - roles - photos - tags

works as follows: There are functions of: 1) Photographer 2) Client (who would be the client of the photographer)

That is, a photographer will have multiple clients.

In table photos, I had thought of the columns:

|  photos       |
| id            |
| path          |
| imageable_id  |
| imageable_type|

The imageable_type because for example, the photographer will have the profile image of him, the client also, the photographer may have company image, and when there was a photographic essay, there will be several photos linking the photographer to the client. But in that case would it be missing a column to link the photographer to the client?

For tags

| tags           |
| id             |
| description    |
| taggable_id    |
| taggable_type  |

This one I think is easier because the type, or it will be a tag for the photo or it will be a tag for an essay, just that ...

But with regard to photos themselves, what kind of relationship is it? Polymorphic ManyToMany ??

I hope you have explained it successfully, thank you!

    
asked by anonymous 15.08.2017 / 03:04

1 answer

0

I see some relationships ...

Following the business idea (correct me if you need adaptation):

**Users** (contém Cliente e Fotográfo)
id
nome
cpf 
login
senha
ft_perfil
> outros dados, se necessário

* Login and password, you can by a separate table to a control when the person misses password or you want to change and maintain a history to not allow the same passwords. I would stay:

**acesso**
id_user (fk da Users)
login
senha
nr_tentativas (definir limite de tentativas quando a pessoa errar)
status (bloqueado, ativo, inativo)

How photographers have n clients:

**r_fotografo_cliente**
id_fotografo (fk da users)
id_cliente (fk da users)
dt_associacao (data em que o fotografo foi associado a este cliente)
(ambos FK da user)

As this combination of formed, there are photos ...

**fotos**
id_fotografo (FK da r_fotografo_cliente para não perder a integridade!)
id cliente (FK da r_fotografo_cliente para não perder a integridade!)
path          
imageable_id
imageable_type
    
04.09.2017 / 17:04