When are databases used?
Explain some places where databases are used
School use:
- learning platforms such as Google Classroom
- management information systems such as SIMS or iSAMS
Organisation and business use:
- customer relationship management (CRM) software
- online calendars such as Google calendar
- the backend of most website to dynamically generated pages
Personal use:
- social media data
- multiplayer games
What is a database?
Data types
Just as when programming variables, database fields need to have a data type. The possible database data types to choose from are:
- Integer (whole number)
- Real, float, decimal (number with a decimal component)
- Data, Time, Datetime (to store dates and times)
- Char (fixed length string up to 8,000 characters)
- Varchar (variable length string up to 8,000 characters)
- Text (variable length string up to 2 GB of data)
Flat file databases
What is a primary key?
A field that stores unique data for each record in a table
Relational databases
What is data redundancy?
When there is unnecessary data repetition in a database
What is a foreign key?
A field in a table that references the primary key of another table
What are the three possible relationship between tables in a database?
Relationships between tables can be:
- one-to-one
- many-to-many
- one-to-many
What does SQL stand for?
Structured Query Language
What is SQL?
Writing a query using SQL
The SQL syntax for querying a database is:
SELECT… list the fields to be displayed
FROM… specify the table name
WHERE… list the search criteria
What are the benefits of using relational databases?
They eliminate data redundancy and inconsistency
What are the benefits of using relational databases?
They eliminate data redundancy and inconsistency
What is SQL?
A language used for querying and updating database tables in a relational database
When is the SELECT statement used?
To extract a collection of fields from one or more tables in a database
What is the syntax of the SELECT statement?
SELECT list of fields to be displayed
FROM list the table or tables where the data will come from
WHERE list of search criteria
ORDER BY
list the fields that the results are to be sorted on (either ASC or DESC)
What is the default setting for ORDER BY?
Ascending
What does the INSERT INTO statement do?
Used to insert a new record into a database table
What is the syntax for the INSERT INTO statement?
INSERT INTO tableName (column1, column2,…)
VALUES (value1, value2,…)
What does the DELETE statement do?
Used to delete a record from a database table
What is the syntax for the DELETE statement?
DELETE FROM tableName
WHERE column = value