[Chloe Walt] [Year 2, Semester 1]
Chloe Walt
WLTCHL002 |
,Data Bases:
What is a database?
A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a database
management system (DBMS).
The data can then be easily accessed, managed, modified, updated, controlled, and
organized.
Ways to store data:
1. Remember it
2. Write it down (on paper)
3. Use a spreadsheet
What if many people are using the same data at once?
Different people need access to different parts of the data at once.
A unified access point to the data is needed, so each person can access the subset of data
that they need while everyone is accessing the same underlying data store. A DATA BASE is
needed.
Relational Data Bases:
A collection of tables.
relational databases enable users to manage predefined data relationships across
multiple databases. It helps recognise relations between stored items of information.
Terminology:
1. Attribute: A column (ie. ID, first name, last name)
2. Relation: Technical word for a table. A table defines a relationship between various
columns (i.e. ID of a book to the title of the book)
You can also get relationships across tables (i.e. Book and author's ID in one table, and
name of author in another table (use the ID to get name)).
3. Degree and Cardinality:
- Degree: Number of columns
- Cardinality: Number of rows
1
,Synonyms of the terminology that come up:
The language that we typically use to query relational databases is SQL (Structures Query
Language)
2
, Using SQL:
Commands:
Limiting Columns:
SELECT * FROM family_members
[Selects every column in table family_members]
SELECT name, species, num_books_read FROM family_members
[Selects only the columns specified]
Limiting Rows:
WHERE num_books_read > 100
[Will only print the two rows where the number of books read is greater than 100]
SELECT * FROM friends_of_pickles //Looks at all columns in friends_of_pickles table
WHERE species = 'dog' AND height > 38 //specifies species row, finds items that are dogs
// and their height is > 38
3