Solved

what is the difference between schemas and catalogs?

Posted on 2008-10-24
8
3,456 Views
Last Modified: 2012-05-05
hello experts,
i'm using pgAdmin to interface postgresql,

i've create databases, my databases contains: schemas and catalogs,
but inside a schema there's the same elements than in a catalog:
Aggregates,  Domains, Functions, Sequences, Tables, Trigger Functions, Types, Views.  

what is the  difference between the two?
0
Comment
Question by:toshi_
  • 3
  • 3
8 Comments
 
LVL 12

Assisted Solution

by:hfraser
hfraser earned 350 total points
Comment Utility
Catalogs are simply tables (like any other) that contain information about the database, like tables, indices, operators, functions. data types, etc.. Since Postgres is extensible, this information (like new data types) is cntabined in tables you can add too, rather than coded into the engine directly.

Schemas is a namespace. It contains catalogs and tables, but is separate from other schemas, allowing multiple definitions for a new data type or function to be used within the same database. You might, for instance, have development environments for two groups hosted on the same database, but kept in different schemas to prevent naming conflicts.
0
 

Author Comment

by:toshi_
Comment Utility
as i see it in pgAdmin,
there's just the icon that is different,



catalog-vs-schema.png
0
 

Author Comment

by:toshi_
Comment Utility
what could i do in schemas that i can not do in catalogs and vice-versa?


0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Accepted Solution

by:
hfraser earned 350 total points
Comment Utility
Remember that Postgres is extensible, meaning that you can define new datatypes, operators, functions, etc.. These extensions are not like an attribute of a table; they are completely new types of data (like the standard int, text, float, etc.) and the operators that work on them (like +,-,/,*).that apply to any queries, tables, etc.. So if you've created a new datatype called widget, you're free to create a table with an attribute in it called widget, re-define the "+" function to do something meaningful when you add two widgets.

But maybe someone else has another project that defines their own datatype called widget. Schemas allow you to have multiple sets of these extensions within Postgres. Depending upon which schema you choose to use, you will inherit the extensions defined in that schema. By creating separate schemas for each of these environments, you can support both definitions.

My example's a bit lame, but hopefully it gets the idea across. Most uses of Postgres I've seen never delve into extensions, and don't use schemas.
0
 

Author Comment

by:toshi_
Comment Utility

Most uses of Postgres I've seen never delve into extensions, and don't use schemas.?


so what do they do?

0
 
LVL 12

Assisted Solution

by:hfraser
hfraser earned 350 total points
Comment Utility
Use it as a standard database out of the box The extensions and schema support are only necessary if the standard offerings don't meet your requirements.
0
 
LVL 3

Assisted Solution

by:brycen
brycen earned 150 total points
Comment Utility
With schemas, you can create separate namespaces:
bnesbitt=> create table foo (foo_key integer, foo_text varchar(1024));
bnesbitt=> create schema api2;
bnesbitt=> create table api2.foo (foo_key integer, foo_int integer);
Here "select * from api2.foo;" returns different results from "select * from foo" (which is really "select * from public.foo".  The default schema is called "public".
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now