Unit 7 Relational databases and SQL Flashcards
When are databases used?
- Databases are used in many business situations
- They are also used at the back-end of many cloud services
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?
- A database is a structured way to store data so that it can be retrieved using queries
- Contains one or more tables
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
- A flat file database stores a single table of data inside a single text file
- Flat file databases are often stored using a CSV (comma separated values) format
- Each record appears on a separate line, each field is separated by a comma
- This format is very easy to set up, however, it is hard to manage for anything but the simplest of data sets
What is a primary key?
A field that stores unique data for each record in a table
Relational databases
- A relational database contains multiple tables that are linked together using relationships
- Relational databases allow us to design tables that reduce inconsistencies and eliminate data redundancy
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?
- A language which allows you to create, query, update and delete data to and from databases
- SQL is used with most Database Management Systems, including MySQL, SQL Server and MS Access
- SQL queries can be used within high level programming languages such as Python
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