Solved

what is the difference between schemas and catalogs?

Posted on 2008-10-24
8
3,660 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 12

Assisted Solution

by:hfraser
hfraser earned 350 total points
ID: 22796149
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_
ID: 22797276
as i see it in pgAdmin,
there's just the icon that is different,



catalog-vs-schema.png
0
 

Author Comment

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


0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 12

Accepted Solution

by:
hfraser earned 350 total points
ID: 22798444
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_
ID: 22810544

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
ID: 22811040
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
ID: 22860175
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.

733 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