Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Database query

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

Gazdaman
I did a trackday!!!



Joined: 12 Aug 2004
Karma :

PostPosted: 03:33 - 18 Aug 2006    Post subject: Database query Reply with quote

Ok, say I've got a table called Orders. I have a field for ProductID, which is linked to another database (yes we're talking relational here people).

I want to have space for at least 10 different productIDs in my order table. Does that mean I need 10 fields, Prod1ID, Prod2ID.

Or is there another, simpler way that I'm just missing.

I realise my explaining isn't exactly spot on. Just if someone orders one product, that means I have 9 fields left blank.

It's like, if you build a small house, you'd only build it on a small piece of land, you wouldn't build a tiny house on a massive plot of land. I just think I'm missing something by reserving all this space in case someone orders 10 different things.

This is for a piece of coursework btw, it's all theoretical, there is no datebase (or spoon?) at the moment it's just an entity relationship diagram. I don't think I can make the entity expand to accomodate the information being given to it. Like as it stands I've defined the boundaries, and if it's not used, it just lays blank.

Anyone have any input? Strange subject I know.

Gaz
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 07:23 - 18 Aug 2006    Post subject: Reply with quote

Hi

Sounds more like you need an extra table.

Product Table (listing all the products)
Order Table (listing all the orders)
Order Item Table (listing each of the individual items on an order).

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Jesus_Christ
Spanner Monkey



Joined: 25 Jul 2006
Karma :

PostPosted: 09:15 - 18 Aug 2006    Post subject: Reply with quote

Or have a non unique order number so you can have multiple entries with different products but the same order number. That way you still have the same number of tables, no large blank spaces and your not buggered if someone orders over 10 items!
____________________
If you ate Stephen Hawking, would that count as one of your "five a day" portions?
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

feef
Energiser Bunny



Joined: 11 Feb 2002
Karma :

PostPosted: 10:35 - 18 Aug 2006    Post subject: Reply with quote

why not have an order ID as well as a uniqe ID in the order table. and th then use a composite primary key. That way you can have multiple records per order, rather than requiring multiple columns for a single order row.

I'm assuming MySQL for the DDI...

CREATE TABLE `order` (
`ID` int(11) NOT NULL auto_increment,
`OrderID` varchar(25) NOT NULL default '',
`ProdID` int(11) NOT NULL default '0',
PRIMARY KEY (`ID`,`OrderID`)
) TYPE=InnoDB;
____________________
Mudskipper wrote: feef, that is such a beautiful post that it gave me a lady tingle Laughing
Windchill calculator - London Bike parking
Blog and stuff - PlentyMoreFish dating
 Back to top
View user's profile Send private message You must be logged in to rate posts

Gazdaman
I did a trackday!!!



Joined: 12 Aug 2004
Karma :

PostPosted: 11:33 - 18 Aug 2006    Post subject: Reply with quote

I never thought of those options!

Ok, back to the drawing board, I appreciate the code there feef too, but this is all theoretical, and there is no database atm. If there was it'd probably (sadly) be MS access.

Thank you all very much!

Gaz
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

feef
Energiser Bunny



Joined: 11 Feb 2002
Karma :

PostPosted: 12:05 - 18 Aug 2006    Post subject: Reply with quote

Gazdaman wrote:
I never thought of those options!

Ok, back to the drawing board, I appreciate the code there feef too, but this is all theoretical, and there is no database atm. If there was it'd probably (sadly) be MS access.

Thank you all very much!

Gaz


Access?? and relational? in the same sentence? :p

Wink

a
____________________
Mudskipper wrote: feef, that is such a beautiful post that it gave me a lady tingle Laughing
Windchill calculator - London Bike parking
Blog and stuff - PlentyMoreFish dating
 Back to top
View user's profile Send private message You must be logged in to rate posts

Marci
Brolly Dolly



Joined: 01 Sep 2005
Karma :

PostPosted: 13:07 - 18 Aug 2006    Post subject: Reply with quote

If you want to look at an existing database that's similar to what you're after, head to www.actinic.co.uk, download their free trial and install. Head to c:\program files\actinic ecommerce v7\sites\site1 and open actinicmaster.mdb (i think)...

That's a complete predone system that runs off an Access-based backend via a custom gui... you can see all the various tables for the various stages of order processing etc.
____________________
FAB-Racing MiniMotoSidecars - Back with a vengeance - F1 Class 2011...
CBR170 engine, custom chassis - www.minimotoscene.co.uk
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

veeeffarr
Super Spammer



Joined: 22 Jul 2004
Karma :

PostPosted: 23:14 - 20 Aug 2006    Post subject: Reply with quote

I've written Access DB's in 3rd NF before no problems.
 Back to top
View user's profile Send private message You must be logged in to rate posts
Old Thread Alert!

The last post was made 20 years, 43 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.08 Sec - Server Load: 0.66 - MySQL Queries: 13 - Page Size: 60.64 Kb