Transcript Lecture 1
IS2803
Developing Multimedia
Applications for Business (Part 2)
Lecture 1: Introduction to IS2803
Rob Gleasure
[email protected]
www.robgleasure.com
IS2803
Today’s lecture
Discussion of IS2803
Continuous assessment
A note on databases
IS2803
What are we covering?
PHP
SQL
XML
Semi-structured and unstructured data
Continuous Assessment
Date tbd
TheBigScreen website was a hit! The company that commissioned
you to build it is so excited by the new business it is generating that
they have hired you to expand the existing functionality to allow new
reviews to be entered by users
The new functionality concerns
The creation of user accounts
The addition and display of user reviews
Continuous Assessment
Login functionality
You have been asked to add login/register functionality to the site, so
that registered users can enter reviews.
The company have requested this information be stored in an MS
Access database, as this is most compatible with their existing
software.
Each user record must contain:
A unique username
A password
Continuous Assessment
Login functionality (continued)
Once a user has logged in, their name should be presented
discretely on each page, e.g. if a username is ‘Frank’, there should
be a simple message which says ‘Welcome, Frank’.
Every page must contain a logout button which logs out a user and
returns them to the homepage
Continuous Assessment
User review functionality
Users must be capable of entering one or more reviews for each
album
Each album on the website must display all user reviews, along with
the username of the person who provided it
The company have requested that a second MS Access database
table be included to store these reviews
Each movie review record must contain:
The movie to which the review refers
The username of the reviewer
The text of the actual review itself
CA – a 'how to'
The steps required
Create an MS Access database with a users table and a reviews
table
Each page must contain some php code that checks if a session
variable called logged_in exists for that user
If yes, it should simply output Hello + that person's username,
e.g. 'Hello Ruddiger' and a logout button that redirects to
logout.php
If not, it should output a HTML form with (1) a username textfield
(2) a password textfield (3) a 'login' button that sends this
information to login.php
CA – a 'how to'
The login.php page must
Connect to the users table in the MS Access database
Send a SQL query to this table requesting the password for that
user
Compare the password provided with the password for that user
in the database and if they match, create the logged_in session
variable to store the user's name
Return to the homepage
The logout.php page must
Destroy the logged_in session variable
CA – a 'how to'
Each album page must
Contain PHP code that checks if a user is logged in and, if so,
displays a form that includes (1) a textarea in which to type
reviews and (2) a button to submit the review
Send this data to add_review.php when the button is clicked
This add_review.php page must
Connect to the reviews table in the MS Access database
Send a SQL query to this table updating it with the new review,
including the movie being reviewed, the review text, and the
name of the user
Return to the homepage
A little bit on databases, while we’re here
Database design is a huge area, about which we could (and people
often do) speak for an entire module
This class is intended to give you a working understanding of some
concepts such that you can design a logical working database for a
medium-sized Website
What is a database?
A database is a central data store where data is recorded and
maintained in some standardised way
The data is organised in a way that allows both individual data items
to be accessed, as well as related groups of data
For our purposes, a database can often be thought of as a table,
consisting of rows and columns
Each column represents one 'field' , i.e. a set of values that an
instance of a data type may possess
Each row represents one 'record', which states the values for one
instance of that data type
What is a database?
Imagine the following database
These columns represent 'fields'
These
rows
represent
'records'
ID
Firstname
Surname
1
Enda
Kenny
2
Eamon
Gilmore
3
Micheál
Martin
4
Gerry
Adams
5
Joe
Higgins
Combined, fields and records represent one 'table'
Relational Keys
Primary keys
Usually one field in a table will act as the primary key
This key acts as a unique identifier for any particular record
As a result of this, the values in this field must be unique
e.g.
In a table of registered users, we might use email addresses or their
screen name
Foreign key
We sometimes also have a field that acts as a foreign key to some
other database table
This foreign key will match to the primary key in the other table,
hence allow us to link together records across tables
Why do we use databases in Web
Development?
There are a number of cases where we want to store related groups
of data, e.g.
Registered users of a Website, including their names, email
address, etc.
Products that we sell, including specifications, price, etc.
Reviews of products that have been left, including who submitted
the review, the date of the review, etc.
Designing a database
As with all design, the first thing we must consider is what we are
trying to achieve
We can then consider what information we need to store
There are two basic approaches to database design
Top-down
Bottom-up
Top-down vs. bottom-up database design
Top-down design
Usually begins with the question: what are the 'things' about
which I want to store data?
Each 'thing' will be the type of record stored in one table
Next we ask, what characteristics of these 'things' are important?
These will be our fields
Bottom-up design
Usually begins with the question: what data units do I need in
order to make my site work?
These data units will be our fields
Next we ask, how do these group together?
Each group will be the type of record stored in one table
Top-down vs. bottom-up database design
Advantages of top-down design
Can be used to make sure multiple developers are on the same
page from the off
Allows for very systematic and logical design which may be
easier to maintain
Starts simple
Advantages of bottom-up design
Gets results quickly
More suitable where development of the website is iterative and
changes are expected
Functionalities can be added/removed more easily
Database Management Systems
A Database Management System (DBMS) is a software package
designed to store and manage databases.
This is different from a database file for several reasons
DBMS makes tables visible and generates reports
DBMS helps less technical users to use data efficiently
DBMS protects data from inconsistency and duplication due to
multiple concurrent users
DBMS handles crash recovery
DBMS handles security and access control
Database Management Systems
DBMS operates at the physical level
Management
and business
users
Conceptual model
Logical model
Database
administrators
System
analysts
and
designers
Physical model
This is where data handling becomes increasingly technical
Database Management Systems (DBMS)
A DBMS is a software program that allows us to create, use and
maintain a database
These come in several categories
Desktop DB
e.g. MS Access
Enterprise DB
e.g. Oracle
Open Source DB
e.g. MySQL
We'll be using MS Access
in this course
Want to read more?
Links and references
An article on top-down vs. bottom-up information system design
http://superprofundo.com/2010/12/13/top-down-and-bottomup-pros-and-cons/
Nice article/book chapter on entity-relationship modelling
http://www.databasedesign.co.uk/bookdatabasesafirstcourse/
chap3/chap3.htm