Live data from Hacker News

PostgreSQL Schema Design

graphile.org

41–42 of 42 posts

Re: PostgreSQL Schema Design

#41

Earlier quoted context omitted.

In general , "schema" refers to the design of database elements -- table names, tables' columns and their names and types, function names and prototypes, etc. In some RDBMSes "schema" also refers to a namespace that qualifies type, table, view, materialized table, and function names -- this qualifier is optional, so you don't always see it, but all obtjects' fully qualified names include the schema name. This overloa…

And the confusion/overloading of the term is even worse than this - in Oracle the concept of "schema" overlaps with "user". In other words, owner of the object and namespace of the object overlaps. It makes sense that the owner of an object is like saying the object belongs to a namespace, but coupling user to that takes getting used to in systems that do that. The ANSI SQL standard (I think part 11) describes the fo…

> In the SQL standard, the notion of objects in the same schema being owned by different users does not exist. Moreover, some implementations do not allow you to create schemas that have a different name than their owner. In fact, the concepts of schema and user are nearly equivalent in a database system that implements only the basic schema support specified in the standard.

--- https://www.postgresql.org/docs/current/ddl-schemas.html

Re: PostgreSQL Schema Design

#42

Earlier quoted context omitted.

Indeed, this means that it is logically impossible to connect to postgres and create a database, at least through a normal connection. But you can create a schema with the CREATE SCHEMA statement.

You can create databases via sql [1]. It's just that after you run the statement, you're still connected to the old database and you need to disconnect in order to connect to the new one. [1]: https://www.postgresql.org/docs/current/sql-createdatabase.h...

Wow, I had no idea. Thank you so much!

(A few lost internet points from the downvotes are well worth it for that gem of knowledge.)

Post reply on HN