on getting started with databases for COMP2041
a reply-to-public; written 2017-10-22

Here’s some (fairly general) advice on how to get started adding a database to your COMP2041 assignment:

Think about the structure of your data. Work out what ‘entities’ you need to store (users, posts, etc.), and what information is important to an entity; then, work out what relationships exist (e.g., a user has many posts). Draw a diagram to help.

Once you’ve done that, work out how you’ll access that data. You have two real options: SQL, and not-SQL.

  • Non-SQL databases, like DBM or Berkeley DB, would be my recommended solution, just for the ease of setting them up, and for the ease of working with them.

    You will find the tie function useful; do perldoc -f tie to get its documentation. You’ll likely also find DB_File or GDBM_File are useful with that.

  • SQL databases, like SQLite3, are also a viable option. I’m more hesitant to recommend this option, as it requires learning a new language to manipulate and interact with a database, one with is very easy to misuse.

    SQLite3’s documentation is at https://www.sqlite.org/docs.html and is a thorough reference though a poor introduction. I’d also suggest reading through the documentation for the DBI mechanism, and DBD::SQLite3.

(Of course, if you’re not using Perl, this is absolutely no use to you. I actively recommend against using Python 2 and 3.)