D
D
Dilik Pulatov2019-07-23 10:17:38
PostgreSQL
Dilik Pulatov, 2019-07-23 10:17:38

Schema in Postgresql: why is it needed and how can I use it in my projects?

Hello!
I haven’t worked with Postgresql yet, and I don’t know how it works, what it is better in, and what it is worse than other DBMS.
Recently I started to study Postgresql (I had to implement one project and my friends suggested Postgresql. Before that I worked with MySQL, Oracle)
The project has such a structure, an online store (Buyer, seller, goods, warehouses, orders, etc.) more difficult. and There is one task:
- Online store can sell in other cities. And the database needs to be implemented so that we can give access to the client, and he only works with his city, and at the same time all the data will be in one database but should not be mixed. with other cities.
I've read about Postgresql schema, but I don't really understand what Postgresql schemas are all about, but I think. can I use Postgresql schema in my projects? and what is the best way to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2019-07-23
@melkij

Isn't there schemas in oracle?..
schema - an additional level of object structuring. Like namespace in programming. And, by the way, it is included in the SQL standard.
You can do tables:
user_subscriptions
user_orders
user_favorites
You can do
user.subscriptions
user.orders
user.favorites
And it makes no difference to a DBMS. But it may be convenient for a developer to operate not with a hundred tables in one list, dozens of which have the same prefixes (because they refer to their entities), but separate schemas by entities.
Sawing one table into several senses is not so much, but the hassle is added.
If you want to give direct access to the database to the user, then why? You don't have to do this in a shared environment. Any DBMS can be put in some interesting query. And the fact that people will sometimes write interesting and highly creative requests - I guarantee you from DBA experience. Sometimes they do something like this ... 0.5tb of temporary files with one request, for example. Or gobble up 30GB of RAM and take the database into an emergency restart from OOM.

O
OnYourLips, 2019-07-23
@OnYourLips

It is enough to check the rights to actions in the application logic.
Store everything in 3+ normal form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question