E
E
Evgeny Semashko2020-06-30 23:28:27
Database design
Evgeny Semashko, 2020-06-30 23:28:27

Is the correct link selected?

Chose one-to-many binding. It's just that the further I google the correct link, the more dissonance arises that the wrong link is selected.

Essence: There are several regional centers, in these regional centers there are pharmacies and, for example, the user needs to select the regional center, after selecting the regional center, all the pharmacies of this center are displayed to him, then he selects a pharmacy suitable for himself from the list and after selecting the pharmacy, all those located there are displayed to him medicines. In fact, there should be one-to-many binding, but what if the situation is reversed. The user has selected a region and entered the medicine he needs in the search bar, then a list of pharmacies in which this medicine is located is displayed, that is, if you rely on

definition
Связь "один ко многим" являются наиболее распространенным типом связи. В такого рода связях строка в таблице А может иметь много строк в таблице B. Но строка в таблице B может иметь только одну строку в таблице А. Например, таблицы "Издатели" и "Названия" имеют связь "один ко многим". То есть, каждый издатель выпускает много названий. Но каждое название принадлежит только одному издателю.
which maybe I misunderstood, then there is a violation of the connection. And the idea arose that you need to use many-to-many, but it shouldn’t be in any way here at all.
Here is my link diagram .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2020-07-01
@evgenysemashko

Город: Код, Название, …
Аптека: Код, Код города, Название, …
Лекарство: Код, Название, …
Товар:

Код, Код лекарства, Форма, Упаковка, Количество в Упаковке, …

Наличие:
Код хранения, Код аптеки, Код товара, Цена, Количество упаковок, …

A
Arman Hovhannisyan, 2020-06-30
@Armrisch

Everything is not simple here, your situation is a simple one-to-many relationship, one region has many pharmacies and one pharmacy has only one region, in the case of medicines and a pharmacy, a many to many relationship is suitable, since one pharmacy can have many drugs, and one medicine in turn may belong to several stores. If you haven’t worked with a many-to-many relationship before, then here you also need to create a linking table where in the fields you will have something like
Id, pharmacy_id, drug_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question