Re: [GENERAL] Newbie table definition question

2004-10-17 Thread Steven Klassen
* Ken Tozier [EMAIL PROTECTED] [2004-10-17 00:25:07 -0400]: So, assuming there's no quantity field defined in the cart table, if 3 apples, 2 oranges and 1 head of lettuce were purchased on a specific shopping trip, I would do something like this? If you need a quantity field, add one.

Re: [GENERAL] Newbie table definition question

2004-10-17 Thread Steven Klassen
* Steven Klassen [EMAIL PROTECTED] [2004-10-17 01:52:47 -0700]: xinu= select * from items_types_view; id | item_name | type_name +---+--- 1 | Apple | fruit 2 | Orange| fruit 3 | Brocolli | fruit 4 | Lettuce | fruit (4 rows) And after I fixed the

Re: [GENERAL] Newbie table definition question

2004-10-17 Thread Ken Tozier
Thanks again Stephen It helps to see a problem you understand defined in a language you don't. I've got a handhold now. Ken On Oct 17, 2004, at 4:52 AM, Steven Klassen wrote: * Ken Tozier [EMAIL PROTECTED] [2004-10-17 00:25:07 -0400]: So, assuming there's no quantity field defined in the cart

[GENERAL] Newbie table definition question

2004-10-16 Thread Ken Tozier
I'm a C/Objective C programmer and am having a bit of difficulty figuring out how to define SQL table approximations to things that are very easy to do in C/Objective C Basically what I'm confused about is how to simulate arrays of structs in Postgres. For example, if I define a C struct like

Re: [GENERAL] Newbie table definition question

2004-10-16 Thread Steven Klassen
* Ken Tozier [EMAIL PROTECTED] [2004-10-16 13:50:37 -0400]: I'm a C/Objective C programmer and am having a bit of difficulty figuring out how to define SQL table approximations to things that are very easy to do in C/Objective C I sympathize; no matter how many languages you know, there's

Re: [GENERAL] Newbie table definition question

2004-10-16 Thread Steven Klassen
* Steven Klassen [EMAIL PROTECTED] [2004-10-16 17:42:17 -0700]: INSERT INTO grocery_items (grocery_types_id, name, price) VALUES (1, 'Apple', '0.50'); INSERT INTO grocery_items (grocery_types_id, name, price) VALUES (1, 'Orange', '0.75'); INSERT INTO grocery_items (grocery_types_id,

Re: [GENERAL] Newbie table definition question

2004-10-16 Thread Ken Tozier
Stephen, Thanks that does help. Syntax is a bit foreign still. I'm not sure why you defined the grocery_items_id_exists and grocery_types_id_exists constraints though. Is that something that's ever explicitly accessed either through a query or an insert? Or is it one of those things that

Re: [GENERAL] Newbie table definition question

2004-10-16 Thread Steven Klassen
* Ken Tozier [EMAIL PROTECTED] [2004-10-16 22:52:10 -0400]: Or is it one of those things that enforces data integrity behind the scenes? That's exactly it -- one of the most attractive things about the database is that if constraints are defined appropriately it can defend itself from the

Re: [GENERAL] Newbie table definition question

2004-10-16 Thread Ken Tozier
You can track whatever information you need about the particular trip, add rows to the cart associating the trip with the items being purchased, and finally the grocery types and items. CREATE TABLE trips ( id bigserial primary key NOT NULL, created timestamp default now() NOT NULL );