Re: "Smart" Product Codes
From: Alejandro Mesa (AlejandroMesa_at_discussions.microsoft.com)
Date: 10/15/04
- Next message: Aaron [SQL Server MVP]: "Re: database diagrams"
- Previous message: John: "Re: database diagrams"
- In reply to: Mike Labosh: "Re: "Smart" Product Codes"
- Next in thread: Mike Labosh: "Re: "Smart" Product Codes"
- Reply: Mike Labosh: "Re: "Smart" Product Codes"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 15 Oct 2004 13:59:07 -0700
This is not a good idea but try creating a UDF and use this functions to
create the calculated column. Pass four parameters (4 keys) and create the
composite value.
AMB
"Mike Labosh" wrote:
> > If I understood, then you have something like:
> Yes, that's exactly what I have.
>
> > Could you post which columns are the pk of table Product?
> ProductKey
>
> > Could you post the fk constraints defined in table Product?
> VendorKey, OperatingSystemKey, etc.
>
> All of the identity columns are the PK of their respective tables.
>
> > if you have all four natural keys and also an IDENTITY column, why do you
> > want to create a new column that is the concatenation of the four natural
> > ones?
> > How do you plan to use the "smart product code" in your model?
>
> The pointy haired bosses on the "standards committee" hath said from on
> high: "Every table must have an identity column as its sole primary key"
> And it has worked well just about every place in the system. In this
> example though, using the natural keys would make things less complex. But
> I can't change it like that.
>
> In many programs, the 4 natural keys of the 4 lookup tables are used. The
> composite of those four natural keys represents the natural key for the
> Product table, and is passed to external black box systems, and also has
> some significance to our clients.
>
> Any time a program needs to get the whole composite key, it has to join all
> five of these tables to get the four little natural keys and concatenate
> them using ProductKey in the WHERE clause. I thought that having a
> calculated column would make that a lot less painful.
>
> I don't know exactly how they use them, but it is mostly in join's, where's
> and orderby's. I'm not even a DBA either. I'm just the badass .net guy
> they brought in to fix a giant data importing system (which I have now
> inherited from a "fired" consulting firm). Unfortunately, all the code I
> have worked on has been b0rken and I have had to rewrite most things from
> scratch. Sadly, the consulting firm did a bad job of the database design,
> and I have accidentally become the defacto DBA in this migration.
>
> --
> Peace & happy computing,
>
> Mike Labosh, MCSD
>
> "It's 4:30 am. Do you know where your stack pointer is?"
>
>
>
- Next message: Aaron [SQL Server MVP]: "Re: database diagrams"
- Previous message: John: "Re: database diagrams"
- In reply to: Mike Labosh: "Re: "Smart" Product Codes"
- Next in thread: Mike Labosh: "Re: "Smart" Product Codes"
- Reply: Mike Labosh: "Re: "Smart" Product Codes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|