Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #845

Re: how to insert values in two table with single query

From --CELKO-- <jcelko212@earthlink.net>
Newsgroups comp.databases.ms-sqlserver
Subject Re: how to insert values in two table with single query
Date 2011-11-25 08:22 -0800
Organization http://groups.google.com
Message-ID <2cf05a58-b8b1-464f-a7c3-de6bb44a5954@da3g2000vbb.googlegroups.com> (permalink)
References <3dd607ca-010c-4e49-bde8-cef2d1ec603d@z22g2000prd.googlegroups.com>

Show all headers | View raw


 Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Please learn to follow ISO-11179 data element naming
conventions and formatting rules. Temporal data should use ISO-8601
formats. Code should be in Standard SQL as much as possible and not
local dialect.

What you did post, implies that your used an IDENTITY instead of am
key!  Surely you are not that bad a programmer. You have the UPC as
the obvious, nature industry standard key which can be validated and
verified.

Did you notice the horrible attribuDid you fire the guy that did this
to you? The Products Table has no product attributes!  It has physical
store location data , just like the Product_Locational table.

Since you did not bother with basic Netiquette, I cannot give you vaid
DDL. Try this skeleton. Oh, why did you abbreviated “number” as “no”
in one place and then spell it out in another?

CREATE TABLE Inventory
(upc  CHAR(13) NOT NULL PRIMARY KEY
  CHECK (upc LIKE '..'), ,
onhand_qty INTEGER DEFAULT 0 NOT NULL,
<< attributes of products qua products>>);

CREATE TABLE Product_Locations
(upc CHAR(13) NOT NULL
  REFERENCES Inventory (upc),
 shelf_nbr INTEGER NOT NULL
  CHECK (shelf_nbr > 0),
 aisle_nbr INTEGER NOT NULL
  CHECK (aisle_nbr > 0),
 side_code CHAR(2) NOT NULL
  CHECK (side_code IN (..)),
 shelf_position INTEGER NOT NULL
  CHECK (shelf_position > 0),
 PRIMARY KEY (?????))'

Since you failed to give either specs or DDL, I do not know if the
business rules allow the same product in different store locations, so
I cannot even guess at a primary key!

It looks like you need to fire the guy that did this to you. He is
using IDENTITY to build 1970's pointer chains in SQL and had no idea
how RDBMS works. He is dangerously ignorant and the rest of his code
is mostly likely even worse. This is the most basic data model I can
imagine. and it is a mress.

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

how to insert values in two table with single query Pab <prabu.net88@gmail.com> - 2011-11-24 05:27 -0800
  Re: how to insert values in two table with single query Erland Sommarskog <esquel@sommarskog.se> - 2011-11-24 13:53 +0000
    Re: how to insert values in two table with single query Pab <prabu.net88@gmail.com> - 2011-11-24 06:13 -0800
      Re: how to insert values in two table with single query "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-11-24 10:37 -0500
      Re: how to insert values in two table with single query Erland Sommarskog <esquel@sommarskog.se> - 2011-11-24 23:35 +0100
  Re: how to insert values in two table with single query --CELKO-- <jcelko212@earthlink.net> - 2011-11-25 08:22 -0800

csiph-web