Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Databases General > Re: Multi part ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 3150 of 3295
Post > Topic >>

Re: Multi part attributes design question

by --CELKO-- <jcelko212@[EMAIL PROTECTED] > May 5, 2008 at 11:36 AM

Let me try to come with better column names.  Unfortunately, your
specs are weak and it is hard to guess what the key is since you did
not bother with DDL.

CREATE TABLE Products
(product_id INTEGER NOT NULL,
 part_nbr CHAR(1) NOT NULL,
 PRIMARY KEY (product_id, part_nbr),
 -- PRIMARY KEY (product_id, assembly_seq)??
 assembly_seq INTEGER NOT NULL);

If you have assertions, then you can do this:

 CREATE ASSERTION AssemblySequenceCheck
 AS NOT EXISTS
 (SELECT product_id
    FROM Products
   GROUP BY product_id
   HAVING COUNT(*) <> MAX(assembly_seq);

If your SQL is not up to full ANSI specs yet, try this

CREATE VIEW SequencedProducts (product_id, part_nbr, assembly_seq)
AS
SELECT product_id, part_nbr, assembly_seq
  FROM Products AS P1
 WHERE NOT EXISTS
 (SELECT product_id
    FROM Products AS P2
   WHERE P1.product_id = P2.product_id
     AND COUNT(*) <> MAX(assembly_seq)
WITH CHECK OPTION;
 




 6 Posts in Topic:
Multi part attributes design question
Rik Hemsley <rikkus@[E  2008-04-29 05:11:38 
Re: Multi part attributes design question
Rik Hemsley <rikkus@[E  2008-04-29 07:21:40 
Re: Multi part attributes design question
Lennart <Erik.Lennart.  2008-04-29 09:29:41 
Re: Multi part attributes design question
Robert Klemme <shortcu  2008-04-30 23:36:56 
Re: Multi part attributes design question
Philipp Post <Post.Phi  2008-05-01 02:14:49 
Re: Multi part attributes design question
--CELKO-- <jcelko212@[  2008-05-05 11:36:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 9:30:05 CST 2008.