in reply to [Semi-OT] Views, Stored Procedures, and Class::DBI

First off, MySQL 4.0 supports views. (I'm wrong here.) MySQL 5.0 supports stored procedures, triggers and updateable views. As MySQL 5.0 is going to be released any day now, that canard is gone.

As for why you would use each feature, here's a quick primer:


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: [Semi-OT] Views, Stored Procedures, and Class::DBI

Replies are listed 'Best First'.
Re^2: [Semi-OT] Views, Stored Procedures, and Class::DBI
by tilly (Archbishop) on Oct 19, 2005 at 06:13 UTC
    Triggers ... My opinion is that if you are depending on them, you either don't trust your programmers or you build it wrong.

    You say it like that's a bad thing. :-)

    There are times when you really don't want to trust programmers. For instance one common use of triggers is for auditing changes. You don't want to be in a position of having a change in your financial data that you can't explain. Depending on your database (I've seen it demonstrated with Oracle), it is possible to set things up so that nobody - including the DBA - can make a change without it being audited. Sure, you can turn auditing off. But the fact that you turned it off will itself get logged.

    Usually this would be overkill. But there are situations where you really do need to be able to trust, but verify to this level.

      I think you have it exactly right, but I'd like to expand on the example.

      Imagine an organization that has a sizeable group in charge solely of the database -- including replication across many servers, rational backup schemes, auditing and authorizing changes, optimizing queries and maintaining performance, etc. -- and then a wide variety of other groups which both develop applications as well as users using a variety of SQL reporting tools. The entire exercise can get exceedingly complicated and it can be pretty clear how triggers and stored procedures can be immensely useful for the DB group to maintain control.

      From a one database to one application relationship these tools don't seem to make as much sense.

      Mark

      You say it like that's a bad thing. :-)

      *grins* It's not a bad thing. In fact, it's often the only recourse a DBA has, precisely for the kind of reason you're talking about.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re^2: [Semi-OT] Views, Stored Procedures, and Class::DBI
by jgallagher (Pilgrim) on Oct 18, 2005 at 15:34 UTC

    If you create a view for a frequent join, what would be the best way to utilize that from CDBI? I would guess either (1) treating it as a separate table or (2) writing a "search view, map results into the 'real' table types" sub. Perhaps choose (1) if you don't have access to the base tables and (2) if you do?

Re^2: [Semi-OT] Views, Stored Procedures, and Class::DBI
by diotalevi (Canon) on Oct 18, 2005 at 15:39 UTC
    So the views are updatable then?
      That was one of the major features in MySQL 5.0 - the others being triggers, stored procedures, and the NDB table type.

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re^2: [Semi-OT] Views, Stored Procedures, and Class::DBI
by adrianh (Chancellor) on Oct 19, 2005 at 14:15 UTC
    MySQL 5.0 supports stored procedures, triggers and ... views. As MySQL 5.0 is going to be released any day now, that canard is gone.

    Depends what you want to use them for. See the MySQL Feature Restrictions. I'm not even sure it's a complete list since I'm pretty sure that triggers still don't fire on events caused by cascading foreign key actions - and that doesn't appear to be mentioned there.

    The duck's still flying :-)