Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 16th, 2004, 10:28 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
inserting tables

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


Reply With Quote
  #2  
Old March 16th, 2004, 08:22 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: inserting tables

I think the only reason to use foreign keys is to represent the structure of the database more intrinsically, so that you can see the relationships from the foreign keys. Also it stops you dropping tables in the wrong order, which is more of a pest than anything.

I don't think I could go back to working with foreign keys in databases, it really adds no value. Some say cascading deletes is nice, but I think that's just being lazy. Rather make your code exhibit all the behaviour, that way it is contained.

I am no expert on this; I did Oracle a long time ago and recall I hated them very much.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > inserting tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway