A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

On which table should the foreign key be defined?

For simple relational databases the foreign key is usually defined on one table only:
  • For join tables (linking tables), put the foreign keys on the join table itself.
  • For lookup tables, don't put the foreign key on them, put it on the other (main) table.

Flat file vs database

Flat file
  • Easy to set up, only have to consider local file permissions
  • Easy to implement in an ad-hoc way, ideal for a prototype
    • Plain text for very simple things like a list
    • JSON/YAML/Perl for complex data structures
  • Doesn't work when the app is load balanced across multiple servers
  • Not automatically backed up
  • Amazon S3 is relatively expensive
  • Have to make your own model
Database
  • Requires up-front schema design - more work, but forces you to consider design of data 
  • You can put business logic in the ResultSet models
  • Requires an instance to be provisioned
  • Easy cross-referencing of data
  • Works when the app is load balanced across multiple servers
  • Backup-as-a-service (i.e. replication)
  • Amazon RDS is cheaper than S3
  • Get the model for free with ORM
Conclusion

For production services that have redundancy (load balanced), always use a database unless the overhead of setting one up for the first time is considered too high for the business.

Database schema management systems

A list:

Some icons for webpages

A list:

CSS/Layout basics

CSS/styling ideas for developers with little front-end design experience:

  • use Bootstrap
  • get someone with experience to do the graphical design, then implement it using CSS
  • turn a list into a grid of links with JQuery
  • If you want to build something from scratch, the basic principles as I have come to understand them are:
    • (1) decide on an element type, e.g.
      • <span> for in-line elements (in a horizontal line),
      • <div> for a vertical line of elements,
      • <ul> for a list, etc.
    • (2) fiddle with the CSS attributes like: float, clear, overflow, border, padding to make it look like you want.
    • (3) use javascript if anything needs to appear/disappear based on user interaction.
      • But I usually start with a framework layout like Bootstrap, add pre-made Javascript libraries for widgets and only do the above steps for any little tweaks needed.
  • The current state of the art is the "CSS Grid" layout (for 2D grids).
  • Enlightenment and inspiration: CSS Zen Garden
    • examples of the same content transformed with CSS to appear totally different
  • Mozilla Developer Network (MDN) has a good CSS reference
  • CSS tricks has useful guides
  • Quirks Mode tells you which browsers support which features.