inserting table into postgres
Posted: Tue Mar 16, 2004 7:48 am
Hi,
I'm trying to insert some tables into a postgres database, but i seem to be having some problems.
I've inserted a table called advert, which is laid out as follows:
advert_id - (PK)
username
mod_book_id (this links to the another table called module_books on the tables primary key called "id")
asking_price
condition
date_added
ive made the advert_id the primary key, but do i need to make the mod_book_id the foreign key? If I don't, will this cause problems when retrieving data?
i'm doing this in postgress and have already inserted the table using the following:
CREATE table advert
(advert_id int(8),
username varchar(20),
mod_book_id int(8),
asking_price int(6),
conidition varchar(20),
date_added TIMESTAMP,
PRIMARY KEY(advert_id) );
i think I need to make the advert_id an autonumber, and i want the data_added filed to automatically be entered when someone places an advert.
I'm doing this via linux and its command driven, im not sure how to make these above changes to my already existing tables.
Can anyone help?
thanks.
lou
I'm trying to insert some tables into a postgres database, but i seem to be having some problems.
I've inserted a table called advert, which is laid out as follows:
advert_id - (PK)
username
mod_book_id (this links to the another table called module_books on the tables primary key called "id")
asking_price
condition
date_added
ive made the advert_id the primary key, but do i need to make the mod_book_id the foreign key? If I don't, will this cause problems when retrieving data?
i'm doing this in postgress and have already inserted the table using the following:
CREATE table advert
(advert_id int(8),
username varchar(20),
mod_book_id int(8),
asking_price int(6),
conidition varchar(20),
date_added TIMESTAMP,
PRIMARY KEY(advert_id) );
i think I need to make the advert_id an autonumber, and i want the data_added filed to automatically be entered when someone places an advert.
I'm doing this via linux and its command driven, im not sure how to make these above changes to my already existing tables.
Can anyone help?
thanks.
lou