Section 7 - Relational databases and SQL Flashcards

1
Q

What is the concept of a database and relational database?

A

Database:

  • – Collecting information that is organised so it is easily accessible, manageable and updatable.
  • – A database with one table is called a flat-file database

Relational database:
— Multiple tables linked together through their key fields

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What are the following database concepts:
• record
• field
• primary key
• foreign key
A
  • – Records: all the data about one entity shown as rows
  • – Fields: a single piece of data shown as columns
  • – Primary key: a unique field/identifier for every record
  • – Foreign key: a field in a table that is a primary key in another table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why are relational databases better than flat-file databases?

A

— Flat file databases have problems of inconsistency and redundancy therefore these issues are solved using relational databases.

  • – Inconsistency is data being stored differently in the same table
  • – Redundancy is data being stored more than once
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you retrieve data from tables in databases?

A

SELECT field(s)
FROM table(s)
WHERE condition
ORDER BY field ASC/DESC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you insert data into a table?

A

INSERT INTO table(fields)

VALUES (values)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you delete data in a database?

A

DELETE FROM table

WHERE field = value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you edit data in a database using UPDATE?

A

UPDATE table
SET field = value
WHERE condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly