Re: Stuck on creating an easy view, please help
From: Thanks (Thanks_at_discussions.microsoft.com)
Date: 09/09/04
- Next message: JT Lovell: "Re: Cursors; why so many questions?"
- Previous message: JT Lovell: "Re: Question on scope of temp tables created via SP"
- In reply to: Anith Sen: "Re: Stuck on creating an easy view, please help"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 9 Sep 2004 06:43:05 -0700
Thanks for your answer. I had mention the problem with the table design but
redesign apparently is not an option -- that didn't make sense to me so now I
need to figure out a way to answer my question.
"Anith Sen" wrote:
> >> Or do you know of a better way to get the result I want?
>
> Yup. First, you have to reconsider your design. Since multiple values are
> concatenated to form a string for the team, your design suffers from severe
> logical problems inherent to multi-valued systems. A reasonable approach,
> based on your narrative would be to have the tables like:
>
> CREATE TABLE Requests (
> Request_id INT NOT NULL,
> Team_id INT NOT NULL
> REFERENCES Teams ( Team_id )
> PRIMARY KEY ( Request_id, Team )
> );
> CREATE TABLE Teams (
> Team_id INT NOT NULL PRIMARY KEY ,
> Descr VARCHAR(10) NOT NULL
> ) ;
>
> You can have your data like:
>
> INSERT Requests SELECT 240, 2 ;
> INSERT Requests SELECT 240, 3 ;
> INSERT Requests SELECT 241, 1 ;
> INSERT Requests SELECT 242, 1 ;
> INSERT Requests SELECT 242, 2 ;
> INSERT Requests SELECT 242, 3 ;
>
> INSERT Teams SELECT 1, 'SC' ;
> INSERT Teams SELECT 2, 'PE' ;
> INSERT Teams SELECT 3, 'CO' ;
>
> Most query expressions using SQL would be trivial with such a schema & what
> you are requesting is no different. However, if you are looking for a
> concatenated string as your output, I would recommend you extract the
> resultset & do the concatenation leveraging the client programming
> language's string manipulation functions.
>
> --
> Anith
>
>
>
- Next message: JT Lovell: "Re: Cursors; why so many questions?"
- Previous message: JT Lovell: "Re: Question on scope of temp tables created via SP"
- In reply to: Anith Sen: "Re: Stuck on creating an easy view, please help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|