Need A Solution!

Discussion in 'ASP General' started by Arpan, Sep 4, 2005.

  1. Arpan

    Arpan Guest

    Suppose an ASP application which retrieves data from a SQL Server
    database table is accessed by 100 users. Each of the users have a
    password. Assume that the DB table has 25 columns [Column1....Column25]
    & the passwords of 3 users are 'A1', 'B2', 'C3' (excluding the quotes).

    What the application should do is if the password is 'A1', then that
    user should be displayed the records of the columns Column1, Column7,
    Column16, Column20 & Column25 only. If the password is 'B2', then that
    user should be displayed the records of the columns Column3, Column6,
    Column 15 & Column 17. If the password is 'C3', then that user should
    be displayed the records of the columns Column2, Column8, Column11,
    Column17 & Column23, so on & so forth.

    This can be implemented in this way:

    ----------------------------------------
    If(strPassword="A1") Then
    'retrieve Column1, Column7, Column16, Column20 & Column25
    ElseIf(strPassword="B2") Then
    'retrieve Column3, Column6, Column 15 & Column 17
    ElseIf(strPassword="C3") Then
    'retrieve Column2, Column8, Column11, Column17 & Column23
    ................
    ................
    ................
    ................
    ................
    End If
    ----------------------------------------

    This means that there will be 100 If....Else statements which obviously
    will not only be an inefficient approach but also a highly cumbersome &
    tedious one. How can this be implemented more efficiently?

    Please note that all the passwords will be stored in a different DB
    table.

    Somewhat weird, I guess but that's what my client wants!!

    Thanks,

    Arpan
    Arpan, Sep 4, 2005
    #1
    1. Advertising

  2. Arpan

    Bob Lehmann Guest

    >> How can this be implemented more efficiently?
    Probably by normalizing your database, adding user / group tables and
    assigning permissions to the users / groups.

    Or, you could <barf>create 100 VIEWS for each of the users</barf> and do
    your SELECT from the relevant VIEW.

    Bob Lehmann

    "Arpan" <> wrote in message
    news:...
    > Suppose an ASP application which retrieves data from a SQL Server
    > database table is accessed by 100 users. Each of the users have a
    > password. Assume that the DB table has 25 columns [Column1....Column25]
    > & the passwords of 3 users are 'A1', 'B2', 'C3' (excluding the quotes).
    >
    > What the application should do is if the password is 'A1', then that
    > user should be displayed the records of the columns Column1, Column7,
    > Column16, Column20 & Column25 only. If the password is 'B2', then that
    > user should be displayed the records of the columns Column3, Column6,
    > Column 15 & Column 17. If the password is 'C3', then that user should
    > be displayed the records of the columns Column2, Column8, Column11,
    > Column17 & Column23, so on & so forth.
    >
    > This can be implemented in this way:
    >
    > ----------------------------------------
    > If(strPassword="A1") Then
    > 'retrieve Column1, Column7, Column16, Column20 & Column25
    > ElseIf(strPassword="B2") Then
    > 'retrieve Column3, Column6, Column 15 & Column 17
    > ElseIf(strPassword="C3") Then
    > 'retrieve Column2, Column8, Column11, Column17 & Column23
    > ...............
    > ...............
    > ...............
    > ...............
    > ...............
    > End If
    > ----------------------------------------
    >
    > This means that there will be 100 If....Else statements which obviously
    > will not only be an inefficient approach but also a highly cumbersome &
    > tedious one. How can this be implemented more efficiently?
    >
    > Please note that all the passwords will be stored in a different DB
    > table.
    >
    > Somewhat weird, I guess but that's what my client wants!!
    >
    > Thanks,
    >
    > Arpan
    >
    Bob Lehmann, Sep 4, 2005
    #2
    1. Advertising

  3. Arpan

    Jeff Cochran Guest

    On 3 Sep 2005 16:37:37 -0700, "Arpan" <> wrote:

    >Suppose an ASP application which retrieves data from a SQL Server
    >database table is accessed by 100 users. Each of the users have a
    >password. Assume that the DB table has 25 columns [Column1....Column25]
    >& the passwords of 3 users are 'A1', 'B2', 'C3' (excluding the quotes).


    You need a lesson in database design. A user is an entity (table). A
    password is an attribute (column) of that entity. As would be a
    UserName and a UserID (Primary Key). You now have a table with a
    UserID, UserName and Password column.

    >What the application should do is if the password is 'A1', then that
    >user should be displayed the records of the columns Column1, Column7,
    >Column16, Column20 & Column25 only. If the password is 'B2', then that
    >user should be displayed the records of the columns Column3, Column6,
    >Column 15 & Column 17. If the password is 'C3', then that user should
    >be displayed the records of the columns Column2, Column8, Column11,
    >Column17 & Column23, so on & so forth.


    Same deal. You can bet each column is an attribute of something,
    likely something different. Normalize your database, learn to use
    authentication and learn to create an entity relationship diagram.
    Your life will be a lot easier.

    >Please note that all the passwords will be stored in a different DB
    >table.


    Please note that they shouldn't be.

    >Somewhat weird, I guess but that's what my client wants!!


    Clients almost always want a working solution. Almost never would
    thay decide on a seriously flawed implementation. If they did, and
    forced it on a programmer, I'll bet 99% of programmers would turn down
    the job.

    Jeff
    Jeff Cochran, Sep 4, 2005
    #3
  4. Arpan

    Phill. W Guest

    "Arpan" <> wrote in message
    news:...
    > What the application should do is if the password is 'A1', then that
    > user should be displayed the records of the columns Column1, Column7,
    > Column16, Column20 & Column25 only. If the password is 'B2', then that
    > user should be displayed the records of the columns Column3, Column6,
    > Column 15 & Column 17.


    How about another table that links your "condition" against the columns
    that the user should be shown, something like this

    Condition Field
    A1 1
    A1 7
    A1 16
    A1 20
    A1 25
    B2 3
    B2 6
    .... etc. ...

    OK, so you have to /retrieve/ the fields for a given "condition" and
    /build/ them up into a list that you can use in subsequent SQL, but it
    does give you complete flexibility if (or rather, when) the columns
    required /change/ over time.

    NB: I say "condition" because using a single password to access each
    "set" of fields is probably /not/ a good idea - it's amazing how fast
    such "restricted" information moves around ... ;-)

    HTH,
    Phill W.
    Phill. W, Sep 5, 2005
    #4
  5. Arpan

    Arpan Guest

    Thanks Bob, Jeff & Phill for your helpful suggestions.

    Regards,

    Arpan
    Arpan, Sep 5, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Francis
    Replies:
    0
    Views:
    418
    Andrew Francis
    Jun 28, 2006
  2. =?Utf-8?B?Y2FzaGRlc2ttYWM=?=

    Solution file not in the solution folder

    =?Utf-8?B?Y2FzaGRlc2ttYWM=?=, Sep 12, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,108
    Laurent Bugnion
    Sep 12, 2006
  3. , India
    Replies:
    17
    Views:
    1,056
    James Kanze
    Oct 1, 2007
  4. Replies:
    8
    Views:
    511
  5. email55555 email55555

    [SOLUTION] Ruby Quiz #14 LCD Numbers ( solution #2 )

    email55555 email55555, Jan 9, 2005, in forum: Ruby
    Replies:
    16
    Views:
    279
    David Tran
    Jan 10, 2005
Loading...

Share This Page