PHP and the Sakila database – a very short introduction to:
Via the video below you can learn how to:
- Design a database
- Define foreign keys in PhpMyAdmin
- Use the design view
- Export the complete database structure as pdf, svf or dia.
- NB: the reltional tables should use the InnoDB-engine.
Export report in e.g. pdf:
- In design view click “Import / export coordinatesfor relational schema”
- > Operations
- Click the link “Edit or export relational schema”
- Choose your design details, such as A4, portrait, etc. – and save the file.
- So an appendix on your database structure is ready.
When you’re satisfied with some query you can save the query as a view.
PHP and MySQL
- PHP Connect to the database
- Loop out data
- Enter data via a form and save the input.
- View and Delete data (delete.php and deleteAction.php)
- Use the files above. Modify the connect file, and enter your own password and user details.
- Use another table than actors, and create relevant SQL – create, read, update, modify.
- Create SQL that will combine more data from several tables. Use JOINs.
The update file has not been made yet – however the recipe is:
- Loop out a table of actors. Use the delete.php file as a model. Call your file something like modify.php or similar.
- Modify the output, so that the names etc. will appear in a form text input field.
- Hack a modifyAction file. Use the UPDATE keyword in SQL. And use the deleteAction.php file as inspiration.
Advertizing and Databases
Creative advertizers use databases in many ways. Here are some samples:
- AdSlogans. (A collection of slogans)
- Google Analytics. (User tracing and much more)
- Mailchimp. (Mail campaigns)
- Ads of the World.
A Note on Security
For the sake of code clarity I have omited security issues, such as: