SQL relationship

Asked

Viewed 51 times

0

Good evening, I am creating a small system in which I will have a form for Service, where the user will select a Customer, and there will be a checkbox for multiple choice for Services.

Can anyone tell me if my line of thought is correct?

Tables:

*Client
idClient
nominee
...

*Service
idServico
description
service

*Attending
idAtendimento
dating
valorTotal
idServico - N - services
idCliente - 1 - client

  • Service_service
    idAtendimento_Servico
    idAtendimento
    idServico

Use case:
Registering a customer service and 3 selected services via checkbox:

customer service
1                            1        1,2,3

Customer service_service service service
1                            1,1                            1
1                            1,2                            2
1                            1,3                            3

1 answer

4


Needs to have a relational table between care and service, since the relationship between care and service is n-to-n.

Basically, it would look something like this:

inserir a descrição da imagem aqui

  • And the table 'service'?

  • There are those who want to create an ID, there are those who don’t. You may want to create a composite key that is the junction of the atendimento_id and of servico_id, so there will never be duplicates.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.