home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / sybase / 763 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.7 KB

  1. Path: sparky!uunet!ukma!gatech!emory!swrinde!cs.utexas.edu!bcm!mparsons
  2. From: mparsons@fleming.csc.bcm.tmc.edu (Mark Parsons)
  3. Newsgroups: comp.databases.sybase
  4. Subject: Re: Restricting access to rows?
  5. Date: 28 Jan 1993 18:33:35 GMT
  6. Organization: Baylor College of Medicine, Houston, Tx
  7. Lines: 44
  8. Distribution: world
  9. Message-ID: <1k98tvINN8sl@gazette.bcm.tmc.edu>
  10. References: <SPENCER.93Jan27153337@guraldi.med.umich.edu>
  11. NNTP-Posting-Host: fleming.csc.bcm.tmc.edu
  12. Originator: mparsons@fleming.csc.bcm.tmc.edu
  13.  
  14.  
  15. In article <SPENCER.93Jan27153337@guraldi.med.umich.edu>, spencer@med.umich.edu (Spencer W. Thomas) writes:
  16. > I want to restrict access to a table according to the value of a
  17. > certain field, by user, according to a second "authorization" table.
  18. > I.e.,
  19. > create table base (
  20. >     category    int,    /* The field to restrict access by. */
  21. >     data        int
  22. > )
  23. > create table auth (
  24. >     uid        smallint,
  25. >     category    int
  26. > )
  27. > uid    category
  28. > ----    --------
  29. > 2    1        User 2 can see categories 1&2
  30. > 2    2
  31. > 3    3        User 3 can only see category 3
  32. > 4    1        User 4 can see categories 1,2&3
  33. > 4    2
  34. > 4    3
  35.  
  36.     . . . . ideas on view creation deleted . . . 
  37.  
  38. Maybe I'm missing something but . .. . . why do you need or want views?
  39. Why not put the necessary code in your selects/updates/deletes? i.e.,
  40. write the appropriate joins?
  41.  
  42. I've got several places in my application where I need to do this
  43. very same thing, i.e., limiting selects based on values in another
  44. table and the user's privileges.  I just write the joins into my
  45. code.
  46.  
  47. You should be able to just use this as is in your code:
  48.  
  49.     select * from base where category in
  50.         (select category from auth where uid=user_id())
  51.  
  52. Am I missing something?
  53.  
  54. Mark
  55.