SLR 23 - databases Flashcards

1
Q

What are databases used for?

A
  • makes processing data a lot more efficient
  • reduces storage requirements
  • they avoid redundancy (when piece of data is stored in two or more place)
  • allows users to only see relevant data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Why are databases normalised?

A
  • so that they can be efficient without compromises to the integrity of the data
  • it ensures that entities contain no redundant or repeated data
  • allows for faster searching and sorting because the tables are smaller
  • easier to maintain than unnormalized because less duplicated data helping to reduce the number of update, insertion and deletion anomalies that occur.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is the update command used?

A

UPDATE <table> SET <attribute> WHERE <attribute> = <value></value></attribute></attribute>

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

defining a table with SQL?

A

using the CREATE command - can specify table, attributes and data type and well as entity identifiers

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

other need to know SQL:

A
  • Fixed length string CHAR(size) - Variable length string VARCHAR(size) - - Integer INT(size)
  • Number with fractional part FLOAT(size, precision)
  • Date DATE (A date in the format YYYY-MM-DD)
  • Date and time DATETIME
    (A date and time combined in the format YYYY-MM-DD HH:MM:SS)
  • Time TIME
  • Year YEAR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are databases?

A

A structure, persistent collection of data

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

What do you need to analyse about the data before inputting it into a database?

A

what is being -
- input
- processed
- stored
- what the data entities are

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

What are entities?

A

categories that help organisations structure and record their data

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

What would be some entities for a library?

A
  • books
  • librarians
  • rentals
  • customers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are attributes ?

A

Each entity within a database will then be broken down further into more detail, these are called attributes

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

What would be some attributes for the entity students?

A
  • date joined school
  • F name
  • S name
  • DOB
  • grades
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you lay out entities and attributes?

A
  • Entity 1(Attribute 1, Attribute2, Attribute3)
  • we have to underline our identifier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an entity identifier?

A
  • an attribute given to each entity which is unique within that table.
  • e.g., CustomerID​
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What do you have to remember about the primary key?

A

it has to be underlined

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

How can databases be related to each other?

A

common attributes

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

What are the three possible degrees of relationship between databases?

A
  • one-to-one
  • many-to-many
  • one-to-many.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does a one to one diagram?

A

a straight line

17
Q

What does a one to many diagram?

A

a straight line with crows feet at end

18
Q

What does a many to many diagram?

A

a lines with crows feet on either end

19
Q

What is a primary key?

A

an attribute that provides a unique identifier for the entity in a database table

20
Q

Why do we need a foreign key?

A
  • when tables are linked by a shared attribute
  • the attribute must be a primary key in one table and is called a foreign key in the other
21
Q

What is a foreign key?

A

is an attribute in a table which is a primary key in another related table

22
Q

What needs to be created in a many to many relationship ?

A

linked tables

23
Q

What is a table in first form?

A

contains no repeating attributes or groups of attributes

24
What is a table in second form?
is in first normal form and contains no partial key dependencies
25
What is a table in third form?
is in second normal form and contains no non-key dependencies
26
What is a composite primary key?
when you combine attributes to form it
27
When does partial key dependency occur?
in databases with composite primary keys when a non-key attribute doesn't depend on the whole of the composite key.
28
What rea non key dependencies ?
there are no fields that are dependent on other fields that are not part of the key.
29
What is SQL ?
the language used with databases
30
What type of language is SQL?
Structured Query Language is a declarative language - describes the result not the method towards it
31
What are the 4 main SQL commands?
SELECT UPDATE INSERT DELETE
32
The select command
is used for retrieving data from a database table
33
example of how to use the SQL:
SELECT FROM WHERE (ORDER BY ) is optional
34
What is the update command used for ?
modifying the attributes of an existing entity
35
What do update commands usually use to identify which entities to update?
the primary key
36
How is the delete command used?
is used for removing entities from a database
37
code for the delete command ?
DELETE FROM
WHERE
38
How is the insert command used?
to add new records to an existing table
39
How is the insert command used in code?
INSERT INTO (, , ...) VALUES (, , ...)