Database Flashcards

1
Q

What are the 5 Components of a Database System

A

Data
Hardware
Software
Users
Database Access Language

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

What are the 3 attributes of Data?

(Sentences)

A
  • Stored in a single database.
  • Shared among different users.
  • Integrated to ensure consistency and coherence.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the attributes of Hardware?

A
  • Includes secondary storage devices like disks and drums.
  • Supports running the DBMS.
  • Holds stored data in the database.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the attributes of Software?

A
  • DBMS acts as an interface between the physical database and users.
  • Handles user requests to access the database.
  • Shields users from hardware details.
  • Provides facilities for accessing, updating, adding, and deleting data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is CRUD?

A

Create, Read, Update, Delete

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

What are the attributes of Users?

(People that interact with the data)

A
  • Various types of users interact with the database system:
  • Application Programmers.
  • Online users.
  • End users.
  • Database Administrators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the attributes of Database Access Language?

A
  • Allows users to write commands for operations on the data stored in the database.
  • Examples include SQL, My Access, Oracle, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the two Database Access Languages?

A

Data Definition Language (DDL)
Data Manipulation Language (DML)

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

What is Data Definition Language (DDL)?

A

Constructs the database schema. Example: CREATE
command.

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

What is Data Manipulation Language (DML)?

A

Accesses the database, providing statements for
retrieving, modifying, inserting, and deleting data. Example: INSERT command.

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

What are Data Models?

A

Data models describe the structure of the database, including data types, relationships, and
constraints.
- They facilitate communication between users and database designers, helping to understand
the meaning of data and user requirements.

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

What are the 4 Characteristics of Data Models?

A
  • Usability: User-friendly design and ease of modification.
  • Scalability: Adaptable to growth and performance considerations.
  • Maintainability: Ease of maintenance with documentation and comments.
  • Standardization: Consistent naming conventions and data types.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Hierarchical Data Model?

A
  • Organizes data into a tree-like structure with records connected through links.
  • Each record contains fields with single values.
  • Example: Family tree.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the Relational Data Model?

A
  • Represents data as tables (relations) with rows and columns.
  • Each row represents a record, and each column represents an attribute.
  • Example: Student grades tracker.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the Network Data Model?

A
  • Overcomes hierarchical model limitations by allowing a child to have multiple parents.
  • Nodes are connected in a network structure.
  • Example: Research paper network.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the Object-Oriented Data Model?

A
  • Data and relationships contained in objects with attributes and methods.
  • Represents real-world problems using objects and relationships.
  • Example: Personal photo album.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the Entity-Relationship Model (ERD Model):

A
  • Graphical approach to database design defining data elements and relationships.
  • Represents real-world objects and their relationships.
  • Example: Employee entity in an organization.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are SQL Queries?

A

Structured Query Language used for managing and manipulating relational
databases.

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

What are the 3 SQL Queries categories?

A

Data Definition Language (DDL)
- Data Manipulation Language (DML)
- Data Control Language (DCL)

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

What do these SQL things do and their syntax?
SELECT
INSERT
UPDATE
DELETE

A

-SELECT: Retrieves data from one or more tables.

[SELECT column1, column2 FROM table_name WHERE condition;]
- INSERT: Adds new records to a table.

[INSERT INTO table_name (column1, column2) VALUES (value1, value2);]

  • UPDATE: Modifies existing records in a table.

[UPDATE table_name SET column1 = value1 WHERE condition;]

  • DELETE: Removes records from a table.

[DELETE FROM table_name WHERE condition;]

21
Q

What does JOIN do?

A

JOIN: Combines rows from two or more tables based on a related column

22
Q

What are the types of JOIN?

A

INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN

23
Q

What is INNER JOIN?

A

Returns only the rows that have matching values in both tables based on
the specified join condition.

24
Q

What is LEFT JOIN?

A

Returns all rows from the left table (table1) and the matched rows from the
right table (table2). If there is no match, NULL values are returned from the right table.

25
Q

What is RIGHT JOIN?

A

Returns all rows from the right table (table2) and the matched rows from
the left table (table1). If there is no match, NULL values are returned from the left table.

26
Q

What is FULL OUTER JOIN?

A

Returns all rows when there is a match in either the left table
(table1) or the right table (table2). If there is no match, NULL values are returned for the
missing side.

27
Q

What is GROUP BY?

A

Groups rows that have the same values into summary rows.
[SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;]

28
Q

What is ORDER BY?

A

Sorts the result set in ascending or descending order.
[SELECT column1, column2 FROM table_name ORDER BY column1 ASC/DESC;]

29
Q

What is WHERE?

A

Filters records based on specified conditions.
[SELECT * FROM table_name WHERE condition;]

30
Q

What is LIKE?

A

Used in a WHERE clause to search for a specified pattern in a column.
[SELECT * FROM table_name WHERE column1 LIKE ‘pattern’;]

31
Q

What is a Relationship?

A

Associations between entities in a database.

32
Q

What is a Primary Key?

A

Unique identifier for each record in a table.

33
Q

What is a Foreign Key?

A

Attribute in one table that refers to the primary key in another table.

34
Q

What are the types of relationships?

A

One-to-One (1:1)
One-to-Many (1:M)
Many-to-Many (N:M)
Many-to-One (N:1)
One and Only One (1:1)
Zero to One (0:1)

35
Q

What is a One-to-One (1:1)?

A

Each record in one table is related to only one record in another table.

Example: Consider a database for employee information. Each employee may have only one
corresponding record in a table storing their personal details, such as name, date of birth, and
address. Similarly, each employee may have only one record in a table for their employment
history, indicating their hire date, job title, and department.

36
Q

What is a One-to-Many (1:M)?

A

Each record in one table can be related to multiple records in another table.

Example: In a library database, one library member can borrow multiple books, but each
book can be borrowed by only one library member at a time. So, the relationship between the
“library member” table and the “books borrowed” table would be one-to-many.

37
Q

What is a Many-to-Many (N:M)?

A

Multiple records in one table can be related to multiple records in another table.

Example: Consider a database for a university. Each student may enroll in multiple courses,
and each course may have multiple students enrolled. Therefore, the relationship between the
“students” table and the “courses” table would be many-to-many.

38
Q

What is a Many-to-One (N:1)?

A

Multiple records in one table are related to one record in another table.

Example: In a customer-orders database, many orders can be placed by one customer.
However, each order is associated with only one customer. Therefore, the relationship between
the “orders” table and the “customers” table would be many-to-one.

39
Q

What is One and Only One (1:1)?

A

This cardinality constraint means that for every record in one entity (let’s call it Entity A),
there is exactly one corresponding record in another entity (Entity B), and vice versa.

It implies a strict one-to-one relationship between the entities.

Example: A person can have only one social security number, and each social security
number belongs to only one person.

40
Q

What is a Zero to One (0:1)?

A

In this scenario, it’s possible for there to be no related records in the associated entity (Entity
B) for a record in the primary entity (Entity A), but if there is a related record, there can be only
one.

It allows for an optional one-to-one relationship where a record in Entity A may or may not
have a corresponding record in Entity B, but if it does, it’s only one.

Example: A student may or may not have a student ID, but if they do, it’s unique to that
student.

41
Q

What is Zero to Many (0:N)?

A

This cardinality indicates that for a record in one entity (Entity A), there may be zero or
multiple related records in another entity (Entity B).

It represents a one-to-many relationship where each record in Entity A can be associated
with zero or multiple records in Entity B, but each record in Entity B can be associated with only
one record in Entity A.

Example: A customer can have zero or multiple orders placed, but each order belongs to
only one customer.

These cardinality constraints help in defining the relationships between entities in a database,
which in turn aids in designing efficient database schemas and ensuring data integrity.

42
Q

What is Normalization?

A

The process of organizing data in a database efficiently.

43
Q

What are the 6 levels of normalization?

A

1NF
2NF
3NF
BCNF ( Boyce-Codd Normal Form)
4NF
5NF

44
Q

What do you do in First Normal Form (1NF)?

A

Eliminate repeating groups and ensure each column contains
atomic values.

Example: Consider a table named “Student_Courses” where each student can enroll in
multiple courses. Instead of storing multiple course names in a single row for each student, we
normalize it by creating a separate table named “Courses” where each row corresponds to a
unique course. Then, we have another table named “Enrollments” where each row contains the
student ID and the course ID, establishing a one-to-many relationship between students and
courses.

45
Q

What do you do in Second Normal Form (2NF)?

A

Meet 1NF requirements and remove partial dependencies.

Example: Continuing with the “Student_Courses” example, suppose the “Courses” table
includes both the course ID and the instructor name. If the instructor name depends only on the
course ID and not on any other attributes, we remove this partial dependency by creating a
separate table for instructors, thus ensuring that each non-key attribute is fully functionally
dependent on the entire primary key.

46
Q

What do you do in Third Normal Form (3NF)?

A

Meet 2NF requirements and remove transitive dependencies.

Example: Extending the previous example, suppose the “Instructors” table includes the
instructor’s department. If the department depends only on the instructor’s name and not on any
other attributes, we remove this transitive dependency by creating a separate table for
departments. Now, the “Instructors” table only contains the instructor’s name and the
department ID, establishing a direct relationship between instructors and departments.

47
Q

What are Entity Relationship Diagrams (ERDs)?

A

Visual representations of the relationships between entities in a database.

48
Q

What are the components of an Entity Relationship Diagram?

A

Entities (Rectangles): Represented by rectangles, such as “Customer” or “Product.”
Attributes (Ovals): Properties of entities, shown within ovals.
Relationships (Diamonds): Connections between entities, indicated by lines.
Cardinality Notations: Describes the numerical relationship between associated entities.

49
Q
A