Table of delivery types in store

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Table of delivery types in store

Post by bagi »

deliveryType
id; INT PRIMARY KEY AUTO_INCREMENT
name; TINYTEXT
description; TEXT
itemId; INT
Users have rights to add custom delivery type, but for default types price must counts automatically. How I can do that? I have an idea to create much one table with itemId column and some BOOL column for storing flag (automatically it counts or no)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Table of delivery types in store

Post by requinix »

What?

If your problem is finding a way to distinguish default versus non-default delivery types then yeah, I'd probably go for a flag field too.
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Table of delivery types in store

Post by bagi »

delivery
deliveryId; INT
itemId; INT
name; TINYTEXT
description; TEXT

deliveryType
id; INT PRIMARY KEY AUTO_INCREMENT
isAutomaticallyCount; BOOL
Asking for critique. I want to find out type of delivery using deliveryType.id and count a price of delivery
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Table of delivery types in store

Post by Christopher »

Seems like it should be like this:
delivery
id; INT
deliveryTypeId; INT
itemId; INT
name; TINYTEXT
description; TEXT

deliveryType
id; INT PRIMARY KEY AUTO_INCREMENT
isAutomaticallyCount; BOOL
So you could: SELECT delivery.*,deliveryType.isAutomaticallyCount FROM delivery JOIN deliveryType ON delivery.deliveryTypeId=deliveryType.id WHERE deliver.id=42
(#10850)
Post Reply