Create Table

Started by Marcelo Pereiraover 24 years ago3 messagesgeneral
Jump to latest
#1Marcelo Pereira
gandalf@sum.desktop.com.br

Hi All,

I know it is a really single question, but I am without any
reference... Does anyone can help me ?

I have to tables (example): 'seller' and 'sells'

seller:

CodSeller | NameSeller
----------------------
1435 | Mark
2486 | Tim

Sells:

CodSell | CodSeller | Description
---------------------------------
001 | 1435 | xya sfaks
002 | 2486 | sdf sdfsd

So, I can create seller like:

create table seller (codseller integer, nameseller char(35));

My question is how to create 'Sells' and link it with 'Seller', can I
force delete cascades with this relation ?

Thanks in Advance,

See ya,

Marcelo

#2Mike Mascari
mascarm@mascari.com
In reply to: Marcelo Pereira (#1)
Re: Create Table

Marcelo Pereira wrote:

Hi All,

I know it is a really single question, but I am without any
reference... Does anyone can help me ?

I have to tables (example): 'seller' and 'sells'

seller:

CodSeller | NameSeller
----------------------
1435 | Mark
2486 | Tim

Sells:

CodSell | CodSeller | Description
---------------------------------
001 | 1435 | xya sfaks
002 | 2486 | sdf sdfsd

So, I can create seller like:

create table seller (codseller integer, nameseller char(35));

My question is how to create 'Sells' and link it with 'Seller', can I
force delete cascades with this relation ?

How about:

create table seller (
codseller integer unique not null,
nameseller varchar(35) not null
);

create table sells (
codsell integer unique not null,
codseller integer references seller(codseller) on delete cascade,
description varchar(35) not null);

Hope that helps,

Mike Mascari
mascarm@mascari.com

Show quoted text

Thanks in Advance,

See ya,

Marcelo

#3Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Marcelo Pereira (#1)
Re: Create Table

On Mar 13 Nov 2001 10:33, you wrote:

Hi All,

I know it is a really single question, but I am without any
reference... Does anyone can help me ?

I have to tables (example): 'seller' and 'sells'

seller:

CodSeller | NameSeller
----------------------
1435 | Mark
2486 | Tim

Sells:

CodSell | CodSeller | Description
---------------------------------
001 | 1435 | xya sfaks
002 | 2486 | sdf sdfsd

So, I can create seller like:

create table seller (codseller integer, nameseller char(35));

My question is how to create 'Sells' and link it with 'Seller', can I
force delete cascades with this relation ?

CREATE TABLE sells (
codsell INT, -- could be serial
codseller INT REFERENCES seller ("CodSeller"),
Description CHAR(60)
);

Saludos... :-)

--
Porqu� usar una base de datos relacional cualquiera,
si pod�s usar PostgreSQL?
-----------------------------------------------------------------
Mart�n Marqu�s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------