- 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.
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
On which table should the foreign key be defined?
For simple relational databases the foreign key is usually defined on one table only:
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.
Labels:
article,
comparisons,
databases,
file,
files
Database schema management systems
A list:
- Squitch - ?
- DBIx::Class::Migration - verbose but powerful. Use dbic-migration alongside dbicdump
- DBIx::Migration - not the same as, or as good as DBIx::Class::Migration
- DBIx::Migration::Directories
- DBIx::Patcher (used at NAP)
- perl-Monorail - ?
- App::JESP - ?
- Migraine
- Mojolicious::Command::migration - thin wrapper for dbic-migration
- Database::Migrator
- SQL::Schema::Versioned
- mimi
- gh-ost - massive overkill for small apps
Some icons for webpages
A list:
- Glyphicons
- Fontawesome
- JQuery UI (how do you make them bigger? maybe use this?)
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
- Or something more low-tech
- 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.
- How to use "float"
- (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).
- One opinion is that CSS Grid beats Bootstrap for layout
- Flexbox is the more established and better supported method of layout (for 1D lists)
- 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.
Subscribe to:
Posts (Atom)