Unanswered: Beginner question: What kind of database to use for J2EE?
What are the deciding factors in choosing a database for J2EE project (creating portal for a community)? From what I understand, certain db such as PostgreSQL has many features such as stored procedure, triggers etc. So I think it is a good database to base the work on (because I came from PHP, so stored proc and triggers are very useful).
However, with EJB or Hibernate, the need for those features became less. My teammates agree that those features are only for legacy databases, and for creating a new project, a simple data storage such as MySQL would do (even MySQL 3 with no referential integrity, as Hibernate can automatically take care of it). Is this argument valid? I have my doubt though, as I still see people are still keen on using databases with those features.
your teammates are dead wrong. Stored procedures and triggers have major advantages when it comes down to raw performance and ensuring database integrity.
Those of course may not be needed for your project, but that doesn't mean they're useless.
mySQL isn't a real RDBMS at all, it's not stable enough or performant enough for large scale implementations and traditionally lacks features that enterprise class applications require.
The deciding factors when choosing a database server are:
- availabillity. Many customers will have a system in place and require it to be used, so do many hosting providers (especially when you're going to use shared hosting rather than hosting your own servers on their location).
- price/cost. When you are free, those come into play. A specific system may be much cheaper over the life of the project because of reduced maintenance cost despite higher initial investment.
My personal favourite is Firebird. Stable, full featured, high performance, low maintenance, low footprint.
And standards compliant so it's relatively easy to switch to something else if the customer would want to.
a trigger would reliably do it at all times.
If you don't use a trigger you'd have to be dead sure you can rely on everyone ever inserting into that table to religiously update the other table.
Takes only a single person who doesn't know that requirement for things to go seriously wrong.
Triggers can also be used, even more useful, to check whether a record can be deleted.
While you can put some logic in foreign keys, it's often not enough. A delete trigger can check whether some other table depends on the record you're planning to delete and yield an error if that dependency exist.
No such problems here... As always everything depends on your code.
Write crappy code and you get crappy results, doesn't matter whether it's a database trigger or an external program checking the database.
In fact a trigger should be more efficient to determine whether there are relations blocking a deletion than a program calling the database to try and retrieve a record that would block that deletion can ever be.
I'm partly surprised, partly shocked by the lack of consideration in your posts. I would think you would have discussed the type and level of database connection, i.e. the level of JDBC connector. The MySQL connector/j is at version 3.1.12 is a level 4 driver!
But more practically the amount and level of documentation which supports what you are learning surely is a plus. Right now things are advancing at a record pace. Sun Java System Application Server Platform Edition 9 is out. Also check out "Java Feature — Bringing Together Eclipse, WTP, Struts, and Hibernate" in JDJ. They mention MySQL not Postgre. btw, MySQL is at 5.0, soon to go to 5.1. Referential integrity and stored procedures has been a big objective for v5!
and your point? Is mySQL a real RDBMS just because it now has a class 4 driver?
And just because a magazine article uses it in an example instead of something else doesn't make it superior to that something else.
Correct. That's why coding in a way that's database independent is so important.
You often won't know in advance what database you're going to be using in the end (or you think you know and someone changes things on you halfway down the project).
Same with appservers, even hardware platforms and operating systems.
Ever created something that was supposed to be deployed on Websphere with a DB/2 backend on AIX only to end up deploying it on Silverstream with an Oracle backend running on HP-Ux, all the while doing development and testing on iPlanet running on AS-400 with an Oracle database?