Project 6: Design and implement a database using a client-server DBMS (MySQL) and implement a simple program that demonstrates the use of an ORM.
Project 6.1: Install ActiveRecord and conduct a simple test to make sure your environment is ok.
"Oooohhhhnnnnhhh..." you groan. Your head is pounding and for a moment you forget everything except that pain. "What happened to me?" you wonder, "I was just .dumping my schema when --" Your vision clears as you raise your head. You see a suit-wearing clown before you.
"As you can see," says the clown, "we've had our eye on you for some time now, (insert your name). It seems that you've been living two lives. In one life, you're (your name), a student in CSCI403, you have a social security number, you pay your taxes... and you help your landlady carry out her garbage. The other life is lived in computers, where you go by the hacker alias Seekwell and are guilty of virtually every computer crime we have a law for. One of these lives has a future, and one of them does not. I'm going to be as forthcoming as I can be. You're here because we need your help. We know that you've submitted a database to a recent competition and that you have been contacted by a certain individual, a man who calls himself Morpheus. Now whatever you think you know about this man is irrelevant. He is considered by many authorities to be the most dangerous man alive. My colleagues believe that I am wasting my time with you but I believe that you wish to do the right thing. We're willing to wipe the slate clean, give you a fresh start and all that we're asking in return is your cooperation in implementing a simple database-backed program"
"Yeah. Wow," you begin, "that sounds like a really good deal. But I think I've got a better one. How about I give you the finger --"
"Urhm."
"-- and you give me my laptop."
"Hhm, you disappoint me," the clown says as he pulls out a water gun filled with something yellow.
"You can't scare me with this Gestapo crap!" you shout, "I know my rights. I want my laptop!"
"Tell me, what good is a database if you're unable to create a program that uses it? You're going to help us, whether you want to or not."
This step in project 6 is short, but there are potential pitfalls that you must avoid by starting early.
We're going to dive into the code next week, so the first step is to make sure your environment is ready to roll. Or rock. Or rumble. Or rabbits, whatever.
Continue working in a subdirectory of cs403
called project06
. This is your dedicated working directory for all 6.x project assignments.
In this step of the project, you will import a sample MySQL database, install the ActiveRecord ORM and test your installation by implementing a simple feature.
gem
installed.ruby
is in your path.bin
directory is in your path.gem
is in your path.gem install mysql2
and gem install activerecord
. Linux/OSX users, you might use sudo
.)ar_test.rb
, not ar_test.rb.txt
. Be sure to read the script before running it and edit as necessary.At this point, you should have run the script and it should not report an error. If not, resolve the error before continuing.
Create a copy of ar_test.rb called zoolicious.rb. Next:
Notice that the number of users is displayed and that the list is sorted.
Using the MySQL "monitor" or a GUI app, quickly browse the schema. You'll notice that very few constraints have been implemented in this schema. This is intentional -- we will be implementing business rules in the ORM layer, and ALTERing our schema to match.
Copy and paste the body of your zoolicious.rb into blackboard (do not attach).