2.5 Databases and distributed systems

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/37

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

38 Terms

1
New cards

What are databases?

Organised collections of data, which allow for easy storage, management, and retrieval of data

2
New cards

What is it important for databases to have?

Data redudancy - The same piece of information is stored multiple times in different rows (This wastes storage, reduces integrity, and increases chance of inconsistencies as data is changed)

Data consistency - Data is accurate in all stored areas (Data doesnt conflict as it gets updated which would lead to unreliability and poor integrity of data)

Data integrity - Accuracy and reliability of data (no errors/duplicates/missing data) (Unreliabilitys can spread reducing integrity and can lead to communication errors)

3
New cards

What is the structure of a  flatfile database

  • Data is stored in rows and columns

  • Each row represents one records

  • Each column is a field

  • All data is in one table

4
New cards

What is referal integrity?

A validation method for databases that is used when linking tables a record is required to exist in both. (For example primary and foreign keys and these prevent records being added that are not part of the relationship)

It ensures connecting data exists and you cannot delete data that is connected to other data

5
New cards

What are relational databses

They were introduced to solve the problem with flatfile

They have multiple tables linked together with primary keys

Characterisitcs

-Entities (each table in the database)

-Primary key (unique identifier for each record)

-Foreign key (these keys link tables)

-Composite key (Primary key of 2 or more fields)

No two records can have the same primary key

6
New cards

What are benefits of electronic databases?

  • Easier to add/delete/modify data

  • Data is easily backed up/copied

  • Acessibile by multiple people in diff locations at the same time

  • Less mistakes (spelling and copying error etc)

  • Storage is smaller physcially

7
New cards

What are types of database relationships?

One-to-One (Like person to student ID as one field represents one other field)

One-to-Many (Like School to student

Many-to-Many (Like student to classes but will create reduancies so will need to add a new table)

8
New cards

Whats an ERD

Shows how data is organised with entities, atribute and relationships (Like a shop can have many sales)

<p>Shows how data is organised with entities, atribute and relationships (Like a shop can have many sales)</p>
9
New cards

What is indexing

Used to speed up data retrieval by indexing a column by associating an index with certain characters (Like names starting with T)

10
New cards

Pros and cons of indexing?

+Faster retrieval

+Efficient sorting/filtering

+Improve performance

-Overheads

-More storage

-Needs updating with changes

11
New cards

What is normalistation?

Organising data in a relational database to reduce redudancy and improve data integrity.

There are 3 Levels (1NF, 2NF, 3NF)

12
New cards

What is 1NF and its Rules

1s Normalised Form.

It ensures data in a table is organised clearly and efficiently so each value is atomic (cannot be split)

Rules:
-Each column contains 1 value (no lists)

-Each record is unique (each row has primary key)

-Each field is dependant on the primary key

13
New cards

What is 2NF and its rules

2nd normalised form.

Rules:

-It is already in 1NF

-All-non key attributes depend on the whole primary key (Not on a composite)(For example spliting an order table with each product having a product ID and its details so you dont have to repeat them)

14
New cards

What is 3NF Rules

-Must be in 2NF

-Every non-key attribute depends on the primary key and not a non-key attribute

This removes repeated data by creating new tables

<p>-Must be in 2NF</p><p>-Every non-key attribute depends on the primary key and not a non-key attribute</p><p></p><p>This removes repeated data by creating new tables</p>
15
New cards

What is a data dictionary?

A document or table that describes the structure of a database (contains information about how data should be)

Its a reference that says:

-What data exists

-Where it exists

-How its used

16
New cards

What will a data dictionary store for each field?

-Field name

-Data type

-Size

-Constraints (Like if its a key and if it should contain letter ‘s’)

17
New cards

Why are data dictionaries important?

It outlines rules to allow for accuracy and consistency of data.

18
New cards

How is validation used in a database?

It is designed into a data dictionary when creating the table. Restrctions can be set during declaration with constraints

19
New cards

How would i create a new column in a table?

You would:
-Set the data type (like an int would reject a string)

-Reject null values (NOT NULL or instead just keep them)

-Set length checks (truncate data)

20
New cards

How would I format check in a database?

The database does not do that so it needs to be separately implemented

21
New cards

What is data redudancy?

When there are duplicate data in different tables (this compromises consistency as data may not be updated everywhere and also wastes storage)

22
New cards

What is data consistency?

The accuracy of data (all occurances of the same field data are the same value)

23
New cards

What are the benefits of a relational database?

  • Avoids redundancy

  • Easily edited

  • Supports complex queries

  • Consistnet records

  • Data is easily added and deleted

24
New cards

What is SQL

Structures Query Language. Is a general purpose language used to manipulate data in databases and tables

25
New cards

Create table query?

make sure to define NOT NULL, primary keys, foreign keys ,etc

With structure:

<name><data type (char(50) or int)><Primary key/Foreign key><NOT NULL (optional)>

<p>make sure to define NOT NULL, primary keys, foreign keys ,etc</p><p></p><p>With structure:</p><p>&lt;name&gt;&lt;data type (char(50) or int)&gt;&lt;Primary key/Foreign key&gt;&lt;NOT NULL (optional)&gt;</p>
26
New cards

What is numeric data type for create table

numeric(x,y)

x is total digits

y is digits to right of decimal (use 2 for money)

27
New cards

Insert Into [Table] Values[]

knowt flashcard image
28
New cards

select query

knowt flashcard image
29
New cards

where… IN

e.g. WHERE name IN (‘Pete’,’steve’)

instead of where name == pete

30
New cards

AND

where name = ‘peter’ and age = 12

31
New cards

OR

Similar to and but can allow one or both conditions

32
New cards

ORDER BY

ASC

DESC

33
New cards

BETWEEN

BETWEEN ID = 1 AND ID = 2

34
New cards

UPDATE query

knowt flashcard image
35
New cards

DELETE query

knowt flashcard image
36
New cards

Join query

can use where instead of join on

<p>can use where instead of join on</p>
37
New cards

GROUP BY [Field];

You would use this to group data that is associated (such as associating all the cash payments associated with one person and grouping it by cash payments to add all up)

38
New cards

Make sure to end with semi colon

Explore top flashcards