Solved

what is the difference between schemas and catalogs?

Posted on 2008-10-24
8
3,519 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
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

920 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

20 Experts available now in Live!

Get 1:1 Help Now