Database | 9618 CS p1

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/23

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.

24 Terms

1
New cards

What are the limitations of using a file-based approach to store data?

- data redundancy ( data is repeated in multiple files)
- data dependency (changes to data means changes to program accessing the data)
- lack of data integrity (entries that should be the same could possibly be different in different places)
- lack of data privacy (all users have access to all data of a single flat file)

2
New cards

What is meant by file-based approach of data storage?

The data is stored in one or more seperate computer files

3
New cards

What is meant by a relational database?

A way of structuring information in tables made of rows and columns

4
New cards

Describe the features of relational database that address the limitations of file based approach

- multiple tables are linked together (reduces data redundancy)
- program data independence means no data dependance
- different users can be given different access rights (which improves data privacy)

5
New cards

What is an entity in a database?

The concept/object in the system that we want to model and store information about

<p>The concept/object in the system that we want to model and store information about</p>
6
New cards

What are attributes in a database?

A data item represented as a field within a table

7
New cards

What is a primary key?

an attribute chosen to ensure that the records in a table are unique

(Unique identifier for a row (tuple))

8
New cards

What is a foreign key?

a column in one table that points to the primary key in another table

9
New cards

Write a DDL statement to create a database

CREATE DATABASE Name;

10
New cards

Write a DDL statement to create a table

CREATE TABLE Name (
Attribute1 datatype,
Attribute2 datatype,
PRIMARY KEY(KeyName) NOT NULL
);

11
New cards

Write a DDL statement to add a new field to a table

ALTER TABLE Name
ADD FieldName DataType;

12
New cards

Write a DML Statement to add data into a table

INSERT INTO TableName
VALUES (Column1data, column2data)

13
New cards

Write a DML statement to update the data/record in a table

UPDATE TableName
SET Column1=Value1, Column2=Value2
Where condition;

14
New cards

Write a DML statement to display/return a value

SELECT Column1, Column2
FROM TableName
Where condition;

15
New cards

What is meant by referential integrity?

- making sure tables do not try to reference data which does not exist
- a primary key cannot be deleted unless all dependant records are already deleted
- a primary key cannot be updated unless all dependant records are already updated
- the foreign keys must be the same datatype as the corresponding primary key

16
New cards

Explain how a retaional database can help to reduce data redundancy

- each record of data is stored once and is referenced by a primary key
- data is stored in individual tables
- tables are linked by relationships
- by enforcing referntial integrity
- by going through the normalization process
- by the proper use of primary and foreign keys

17
New cards

How are primary and foreign keys used to link data?

If Name is the primary key in Table 1, it links to Name which is the foreign key in Table 2

18
New cards

How is DBMS software used to ensure security of data?

- access rights: only certain usernames can read certain parts of the data (can be read only or full access)
- issues usernames and passwords: stops unauthorized access to the data
- encryption of data: If there is unauthorized access to the data, it cannot be understood
- regular backups: a copy of data is available incase it is lost or damaged

19
New cards

What is normalization?

A method to remove or reduce the repetition/redundancy of data

20
New cards

What are the requirements for 1NF?

- no repeated groups of attributes
- all attributes should be atomic (cannot be decomposed into meaningful components)
- no duplicate rows

21
New cards

What are the requirements for 2NF?

- should be in 1NF
- no partial dependency

22
New cards

What are the requirements for 3NF?

- should be in 1NF and 2NF
- no non-key dependency
- no transitive dependency

23
New cards

Name and describe levels of schema of database.

- external schema:
the individual's view of database

- conceptual schema:
describes the views which user of the database might have

- logical schema:
describes how the relationships will be implemented in the logic structure of the database

- physical/internal schema:
describes how the data will be stored on the physical media

24
New cards

Write a statement to delete existing records in a table

DELETE FROM tableName
WHERE condition;