Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Web Buyers Guide
Go Back   Dev Shed ForumsDatabasesDatabase Management

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 Dev Shed Forums Sponsor:
Lose your application development headaches. Start developing and deploying applications with Advantage Database Server today. Download a 30-day trial for Free!
  #1  
Old April 20th, 2002, 10:38 AM
evismaniac evismaniac is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 2 evismaniac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Try this from a past degree exam paper....!

Hi, a work collegue gave me this to try from a final year degree exam paper as a challenge. If you think you can get your head round it go for it....Its a hard one. Here goes:

Write a query that lists the names of those suppliers who have an entry on the suppliers spreadsheet for cd items who have never been asked to satisfy a customer order item through the back order route.

The tables for this are as follows:


Table 1= Item


ItemCode (primary key)

Description
Format
Unit price
Stock Level

----------------------------------
Table 2 = Customer

CustomerId (pk)

CustName
CustAdd
CustTel

---------------------------------
Table 3= CustOrderHead

CustOrderNo(pk)

CustomerId (FOREIGN KEY)
OrderDate
CcDetails
CcStatus
PostandPack

--------------------------------
Table 4 = CustOrderItem

CustomerOrderNo (pk)(fk)
ItemCode(pk)(fk)

CustOrderQuantity
CustOrderUnitPrice
Comments
DateActioned

--------------------------------
Table 4 =BackOrderDetail

CustOrderNo(pk)(fk) | this character is inserted to show that CustOrderNo and itemCode
ItemCode (pk) |is related to Table 4 = CustOrderItem, CustomerOrderNo and ItemCode
ItemCode(pk)(fk
SupplierId (pk)(fk)

DateRaised
Comments
DateActioned

--------------------------------
Table 5 = Supplier

SupplierId (primary key)

SuppName
SuppAddress
SuppTel

----------------------
Table6 = SupplierItem

SupplierId (composite key)
ItemCode(composite key)

SuppCatalogueNo
SuppFormat
SuppDescription
SuppUnitPrice
Delivery

Well im stuck with it anyway....good luck!

Reply With Quote
  #2  
Old April 20th, 2002, 01:09 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to MattR
Mmmm.. SQL!!

I'm not sure I completely understand the requested query, but here's my attempt (I assume the goal is to achive the result with one query and no temp tables or the like in the way?).

Assumptions:
"CD" item is Item.Format = "CD"
"Suppliers Spreadsheet" =
"Customer Order" = Line item in CustOrderItem
"Back Order Route" = Item in BackOrderDetail

p.s. BackOrderDetail isn't designed very well, since you have SupplierID stuck in there even though there's a supplierID in the ItemCode table. Plus item code is there twice?

Code:
SELECT s.SuppName
  FROM Supplier S
 INNER JOIN SupplierItem SI
         ON SI.SupplierID = S.SupplierID
 INNER JOIN Item I
         ON I.ItemCode = SI.ItemCode
        AND I.Format = 'CD'
 INNER JOIN CustOrderItem COI
         ON COI.ItemCode = I.ItemCode
 WHERE s.SupplierID NOT IN ( SELECT DISTINCT SupplierID
                               FROM BackOrderDetail BOD
                              WHERE BOD.ItemCode = COI.ItemCode )


So if I wrote that correctly we'd want to get Supplier Names who stock items which have been purchased (COI table) and are Format 'CD', then disregard all Supplier IDs which exist in the BOD table for any items found in the first query.

Although I can't remember if you can reference COI in the WHERE clause...

Reply With Quote
  #3  
Old April 20th, 2002, 04:48 PM
evismaniac evismaniac is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 2 evismaniac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, thanks for having a go, I definately think your on the right track although I'm a novice....

....I'll try to get the answer and post it....!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Try this from a past degree exam paper....!


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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