473,692 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

relation vs table...

I don't know what Postgres considers a relation and had no intention of
creating one when piping my schema to it... I always DROP TABLE before
CREATE TABLE, so here are the ERRORS emitted when building the database:

3:ERROR: table "country" does not exist
6:ERROR: table "customer" does not exist
11:ERROR: table "product" does not exist
15:ERROR: table "license" does not exist
19:ERROR: table "enduser" does not exist
24:ERROR: table "orders" does not exist
29:ERROR: table "enduser_licens e" does not exist
33:ERROR: table "item" does not exist
37:ERROR: Relation "product_versio n" does not exist
38:ERROR: table "product_versio n" does not exist
43:ERROR: table "ordered_it em" does not exist

but each and every one of these was created via CREATE TABLE

I don't understand why Postgres thinks I am creating a relation _and_ I
don't know what it considers a relation to be. Create stmts follow:

/*============== =============== =============== =============== =============== */
/*
Tables */
/*============== =============== =============== =============== =============== */

DROP TABLE country;
CREATE TABLE country (
country_id VARCHAR(3) PRIMARY KEY,

country VARCHAR(80)
);

DROP TABLE customer;
CREATE TABLE customer (
customer_id SERIAL PRIMARY KEY,
country_id VARCHAR(3) REFERENCES country(country _id),

name VARCHAR(100) NOT NULL,
companyname VARCHAR(100) NOT NULL,
address1 VARCHAR(100) NOT NULL,
address2 VARCHAR(100) NOT NULL,
city VARCHAR(100) NOT NULL,
zipcode VARCHAR(10) NOT NULL,
state VARCHAR(10) NOT NULL,

phone VARCHAR(20),
fax VARCHAR(20),
email VARCHAR(100),
vatid VARCHAR(20)
);

DROP TABLE product;
CREATE TABLE product (
product_id SERIAL PRIMARY KEY,

productdesc VARCHAR(100) NOT NULL,
productname VARCHAR(100) NOT NULL
);

DROP TABLE license;
CREATE TABLE license (
license_id SERIAL PRIMARY KEY,

lickey VARCHAR(80) NOT NULL,
liccode VARCHAR(80) NOT NULL
);

DROP TABLE enduser;
CREATE TABLE enduser (
enduser_id SERIAL PRIMARY KEY,
customer_id INTEGER REFERENCES customer(custom er_id),

name VARCHAR(40),
companyname VARCHAR(40)
);

DROP TABLE orders;
CREATE TABLE orders (
orders_id SERIAL PRIMARY KEY,
country_id VARCHAR(3) REFERENCES country(country _id),
customer_id INTEGER REFERENCES customer(custom er_id),

name VARCHAR(100) NOT NULL,
companyname VARCHAR(100) NOT NULL,
address1 VARCHAR(100) NOT NULL,
address2 VARCHAR(100) NOT NULL,
city VARCHAR(100) NOT NULL,
state VARCHAR(10) NOT NULL,
zipcode VARCHAR(10) NOT NULL,

orderdate DATE,
phone VARCHAR(20),
fax VARCHAR(20),
email VARCHAR(100),
vatid VARCHAR(20),
refno VARCHAR(100),
promotion VARCHAR(100)
);

DROP TABLE enduser_license ;
CREATE TABLE enduser_license (
license_id INTEGER REFERENCES license(license _id),
enduser_id INTEGER REFERENCES enduser(enduser _id),

PRIMARY KEY (license_id, enduser_id)
);

DROP TABLE item;
CREATE TABLE item (
item_id SERIAL,
product_version _id INTEGER REFERENCES
product_version (product_versio n_id),

active INTEGER NOT NULL,
itemname VARCHAR(100) NOT NULL,
unitprice DECIMAL,
numberoflic INTEGER,

PRIMARY KEY (item_id, product_version _id)
);

DROP TABLE product_version ;
CREATE TABLE product_version (
product_version _id SERIAL PRIMARY KEY,
product_id INTEGER REFERENCES product(product _id)
);

DROP TABLE ordered_item;
CREATE TABLE ordered_item (
orders_id INTEGER REFERENCES orders(orders_i d),
item_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,

quantity INTEGER NOT NULL,
product_version _id VARCHAR(10),
unitprice DECIMAL,

PRIMARY KEY (orders_id, item_id, product_id)
);
/*============== =============== =============== =============== =============== */
/*
Indexes */
/*============== =============== =============== =============== =============== */
/*============== =============== =============== =============== =============== */
/*
Procedures */
/*============== =============== =============== =============== =============== */

/*============== =============== =============== =============== =============== */
/*
Triggers */
/*============== =============== =============== =============== =============== */

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
3 11373
On Thu, Oct 09, 2003 at 05:50:48AM -0700, Terrence Brannon wrote:
I don't know what Postgres considers a relation and had no intention of
creating one when piping my schema to it... I always DROP TABLE before
CREATE TABLE, so here are the ERRORS emitted when building the database:


Well, when you do a DROP TABLE and there's no table with the name you
give, the system is right in giving you a "table foo does not exist".
However, when you create a foreign key to a table that doesn't exist
(because you are creating it further down in your script), the system
doesn't know it is a table (it could be a view, for example). So it
falls back to using the more general term, "relation".

"Relation" means, in Postgres terms, "anything that can have a pg_class
entry". This means system tables and views, regular tables and views,
indexes, sequences, TOAST tables and special relations like pg_xactlock
if I'm not mistaken.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Estoy de acuerdo contigo en que la verdad absoluta no existe...
El problema es que la mentira sí existe y tu estás mintiendo" (G. Lama)

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #2
Terrence Brannon writes:
I don't understand why Postgres thinks I am creating a relation _and_ I
don't know what it considers a relation to be.


In the context of relational databases, relation means the same thing as
table. Because of some implementation artifacts, PostgreSQL internally
treats tables, views, indexes, and sequences alike to some extent and
refers to all of them together as relations. So when you see an error
message telling you that a relation was not found, that means PostgreSQL
was looking for a table, a view, an index, or a sequence. This artificial
terminology isn't ideal, but it creates few problems in practice.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #3
On Thu, 2003-10-09 at 13:50, Terrence Brannon wrote:
I don't know what Postgres considers a relation and had no intention of
creating one when piping my schema to it... I always DROP TABLE before
CREATE TABLE, so here are the ERRORS emitted when building the database:

3:ERROR: table "country" does not exist
6:ERROR: table "customer" does not exist
11:ERROR: table "product" does not exist
15:ERROR: table "license" does not exist
19:ERROR: table "enduser" does not exist
24:ERROR: table "orders" does not exist
29:ERROR: table "enduser_licens e" does not exist
33:ERROR: table "item" does not exist
All these are errors when you DROP a table that does not yet exist.
37:ERROR: Relation "product_versio n" does not exist
This is your attempt to have a foreign key reference to product_version
from table "item", when product_version does not yet exist.
38:ERROR: table "product_versio n" does not exist
43:ERROR: table "ordered_it em" does not exist
and again, you are dropping these tables before they exist.
but each and every one of these was created via CREATE TABLE
but only _after_ you try to drop them (and your attempt to create "item"
will have failed because of the bad foreign key reference).
I don't understand why Postgres thinks I am creating a relation _and_ I
don't know what it considers a relation to be. Create stmts follow:


A table is a relation but a relation is not necessarily a table, A view
is a relation. However, the error message for your bad foreign key is
misleading because a foreign key must reference a table, not a relation:

junk=# create view aaa as select * from xxx union select * from zzz;
CREATE VIEW
junk=# create table bbb (id serial, aid integer references aaa(id));
NOTICE: CREATE TABLE will create implicit sequence "bbb_id_seq " for
"serial" column "bbb.id"
ERROR: referenced relation "aaa" is not a table

--
Oliver Elphick Ol************@ lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
=============== =============== ==========
"Every good gift and every perfect gift is from above,
and cometh down from the Father of lights, with whom
is no variableness, neither shadow of turning."
James 1:17
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2900
by: Sharon | last post by:
I have two tables in the DataSet, the first present rooms and the other furniture kinds. Furniture kind, like chare, can be in more then one room. And specific room can contain more then one furniture kind (chare + table + ...). Therefore, the room table should have Relation that point to several furniture kind, and the furniture table should have Relation to several rooms. Is there a way to define this kind of relation from one to...
7
3844
by: Wayne Brantley | last post by:
I have found what appears to be an error in streaming with Datasets. It causes an error of 'Cannot find relation 0' when recreating the dataset from a stream. Here is how you reproduce it. Lets assume you have tables like this: Customers CustomerName: Varchar(50) CustomerNumber: Int (Primary Key)
2
1942
by: jaYPee | last post by:
I have tried almost everything I know but still I can't find a way on how to resolve this problem. I'm using ImportRow to copy some record from 1 table to another table. Here are my code that doesn't work: Dim copyRows() As DataRow = DsStudentCourse1.Tables("Course").Select("CourseCode = 'AUTO 1'") Dim custTable As DataTable =
7
2726
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of relation 149064743 failed 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist So turn on debugging options and have that's what i got:
0
1067
by: brookhartc | last post by:
I am working on a program where I am retrieving data from an Access database through one common dataset. I have already put the database connection component on the form as well as the two data adapters. Here is where I am having problems. I double click on the .xsd file and then go to the schema menu and select add|new relationship. My table names are Employee and Payroll. Employee ID is a primary key in the Employee table and a...
0
2907
by: Ambica Jain | last post by:
I have a data grid called Files, which has some columns like FileName, Col1, Col2, ... , Col8. Then i have a combobox which allows user to select from Col1 to Col8 and based on this selection, i generate a report from data in grid Files. It displays like (e.g. is Col1 is selected): Col1 Count ---------------------- Val1 x Val2 y .....
1
1468
by: Ginger Estherskip | last post by:
I'm setting up a dataset using the GUI to have a Parent Data Table and a few Child Data Tables. I then have a form that uses that dataset, and I can fill the appropriate datatables et. al., but I can't figure out how that parent/child relationship gets enforced? It's a one to one relationship, and when I bind a textedit to the child table row, it's not the row that matches the relation with the parent table. Pretend it's a Shirt
4
5105
bugboy
by: bugboy | last post by:
I'm inserting a new word into table 'w' and a definition into table 'c' which are linked in table 's' which is the relation table for the many to many relationship between 'w' and 'c'. I've been passed 2 variables from a form; $word and $def and i'm inserting them ok but i'm having trouble getting and passing on their ID's in order to insert them into the relation table 's' I've checked every query and they all work individually, so i...
9
1531
by: Miro | last post by:
VS2008 I have created 3 tables. Vendors Customers PhoneNumbers each have their own key Vendor has: VendorID - int unique identifier Customer has: CustomerID - int unique identifier
0
8600
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8794
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8796
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5817
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4322
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4555
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2234
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.