help me god

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/76

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.

77 Terms

1
New cards

What is basic modeling in database design?

Basic modeling involves creating an abstract representation of the data structure in a database. This includes defining the entities, attributes, and relationships that reflect the real-world system.

2
New cards

What are models in the context of database design?

Models in database design represent the structure of data, typically using diagrams such as Entity-Relationship (ER) diagrams or class diagrams. They define how data is stored, organized, and related in a database system.

3
New cards

What are classes and schemas in database design?

Classes are blueprints for objects in object-oriented database design, representing entities or concepts. Schemas define the structure of a database, including tables, views, and relationships, essentially describing the design of the database.

4
New cards

What are associations in database design?

Associations represent relationships between entities or classes in a database model. They describe how different entities are linked, such as one-to-many or many-to-many relationships.

5
New cards

What are object graphs in database design?

Object graphs are representations of interconnected objects in object-oriented databases, showing how objects (or entities) relate to one another. They visualize the relationships between objects in a hierarchical structure.

6
New cards

What is a many-to-many relationship in database design?

A many-to-many relationship occurs when multiple records in one table relate to multiple records in another table. This is typically managed with a junction table that holds the relationships between the entities.

CREATE TABLE students (

student_id INT PRIMARY KEY,

name VARCHAR(100)

);

CREATE TABLE courses (

course_id INT PRIMARY KEY,

course_name VARCHAR(100)

);

CREATE TABLE student_courses (

student_id INT,

course_id INT,

PRIMARY KEY (student_id, course_id),

FOREIGN KEY (student_id) REFERENCES students(student_id),

FOREIGN KEY (course_id) REFERENCES courses(course_id)

);

7
New cards

What is a many-to-many with history relationship in database design?

A many-to-many with history relationship includes a junction table that not only stores the links between the entities but also captures historical data, such as timestamps or change logs, to track the evolution of the relationships over time.

CREATE TABLE student_courses_history (

student_id INT,

course_id INT,

enrollment_date TIMESTAMP,

drop_date TIMESTAMP,

PRIMARY KEY (student_id, course_id, enrollment_date),

FOREIGN KEY (student_id) REFERENCES students(student_id),

FOREIGN KEY (course_id) REFERENCES courses(course_id)

);

8
New cards

What is UML in the context of database design?

UML (Unified Modeling Language) is a standard for modeling the structure and behavior of a system, including databases. It uses diagrams such as class diagrams to represent entities, attributes, and relationships in the system.

9
New cards

What is redundancy in database design?

Redundancy refers to the unnecessary repetition of data in a database. While it can improve performance in some cases, redundancy can also lead to inconsistencies and increased storage requirements.

10
New cards

What is integrity in database design?

Integrity in database design refers to the accuracy and consistency of data. There are various types of integrity constraints, including entity integrity, referential integrity, and domain integrity.

11
New cards

What are functional dependencies in database design?

Functional dependencies describe the relationship between two sets of attributes in a database. If attribute A functionally determines attribute B, then for each value of A, there is a corresponding value of B.

-- Here, student_id functionally determines student_name

CREATE TABLE students (

student_id INT PRIMARY KEY,

student_name VARCHAR(100)

);

12
New cards

What is inheritance in database design?

Inheritance allows one entity (or class) to inherit attributes and behaviors from another entity. In database design, this concept is used in object-oriented models to avoid redundancy and improve reusability.

13
New cards

What are recursive associations in database design?

Recursive associations occur when an entity has a relationship with itself. For example, in a company database, an employee may manage other employees, leading to a recursive relationship within the employee table.

CREATE TABLE employees (

employee_id INT PRIMARY KEY,

manager_id INT,

employee_name VARCHAR(100),

FOREIGN KEY (manager_id) REFERENCES employees(employee_id)

);

14
New cards

What is the relational model in database design?

The relational model organizes data into tables (relations) with rows (tuples) and columns (attributes). It uses keys to define relationships between tables and ensures data integrity and consistency.

15
New cards

What are tables, columns, and rows in relational databases?

Tables store data in rows and columns, representing entities or objects. Columns represent attributes of the entity. Rows represent individual records or instances of the entity.

16
New cards

What are constraints and keys in relational databases?

Constraints enforce rules on data, such as uniqueness or referential integrity. Keys are attributes or sets of attributes that uniquely identify a row in a table (e.g., primary key, foreign key).

17
New cards

What are foreign keys in relational databases?

Foreign keys are attributes that create a link between two tables. A foreign key in one table points to the primary key of another table, establishing a relationship between them.

18
New cards

What are queries in relational databases?

Queries are requests made to the database to retrieve, update, or manipulate data. SQL (Structured Query Language) is the standard language for writing queries.

19
New cards

What are DDL and DML in relational databases?

DDL (Data Definition Language) defines the structure of the database, including creating, altering, and dropping tables and schemas. DML (Data Manipulation Language) deals with the manipulation of data within the database, such as inserting, updating, or deleting records.

20
New cards

What is a join in SQL?

A join combines rows from two or more tables based on a related column, typically a foreign key. Common types of joins are inner join, left join, right join, and outer join.

SELECT students.student_name, courses.course_name

FROM students

INNER JOIN student_courses ON students.student_id = student_courses.student_id

INNER JOIN courses ON student_courses.course_id = courses.course_id;

21
New cards

What are multiple joins in SQL?

Multiple joins occur when you combine more than two tables in a single query. You can use inner joins or outer joins to create relationships between multiple tables.

22
New cards

What are outer joins in SQL?

Outer joins include rows that do not have matching values in both tables, filling in missing values with NULL. Types of outer joins include left outer join, right outer join, and full outer join.

SELECT students.student_name, courses.course_name

FROM students

LEFT JOIN student_courses ON students.student_id = student_courses.student_id

LEFT JOIN courses ON student_courses.course_id = courses.course_id;

23
New cards

What are functions in SQL?

Functions are built-in operations that perform calculations or transformations on data, such as COUNT(), SUM(), AVG(), MAX(), and MIN().

SELECT COUNT(*) FROM students;

24
New cards

What are subqueries in SQL?

A subquery is a query nested inside another query, typically used to filter results or perform operations that depend on the results of the outer query.

SELECT student_name FROM students

WHERE student_id IN (SELECT student_id FROM student_courses WHERE course_id = 1);

25
New cards

What are union and minus in SQL?

UNION combines the result sets of two or more queries into one result set, removing duplicates. MINUS returns the records from the first query that do not exist in the second query's result set.

SELECT student_name FROM students

UNION

SELECT teacher_name FROM teachers;

26
New cards

What are check constraints in SQLAlchemy?

Check constraints are used in SQLAlchemy to enforce rules on column values, such as ensuring that a salary field must always be greater than 0.

27
New cards

What are validators in SQLAlchemy?

Validators are functions or methods that ensure data meets certain conditions before being committed to the database. They are often used in combination with check constraints to ensure data integrity.

28
New cards

What is SQLAlchemy in Python?

SQLAlchemy is an Object Relational Mapping (ORM) library for Python. It provides tools to map Python objects to database tables, enabling interaction with databases using Python objects instead of raw SQL.

29
New cards

What is the document model in databases?

The document model stores data in flexible, semi-structured documents, usually in formats like JSON or BSON. Each document can have a different structure, making this model highly scalable and adaptable.

30
New cards

What are relationships in document databases?

Relationships in document databases are typically represented by embedding documents within other documents (denormalization) or by linking documents through references (normalization).

31
New cards

What is MongoDB $lookup?

The $lookup operator in MongoDB performs a left-outer join to combine documents from two collections. It is used to perform complex queries involving multiple collections.

32
New cards
What is the purpose of **M:N (Many to Many)** relationships in database design?
A Many-to-Many (M:N) relationship connects multiple records in one table to multiple records in another table, often using a junction table.
33
New cards
What does the junction table in an M:N relationship typically store?
The junction table stores the foreign keys that reference the primary keys of the two tables being related.
34
New cards
How do we protect against adding the same major twice in a Many-to-Many without history relationship?
By ensuring that the combination of the foreign keys (e.g., student_id, major_id) in the junction table is unique, we prevent duplicate entries.
35
New cards
What is the **primary key** of the junction table in a Many-to-Many relationship?
The primary key of the junction table is often a composite key made up of the foreign keys from the two related tables.
36
New cards
How does **inheritance** work in SQLAlchemy?
Inheritance in SQLAlchemy allows a class to inherit attributes and behaviors from another class. The `__mapper_args__` attribute is used to define how the inheritance is mapped to the database.
37
New cards
What are the two parameters included in `__mapper_args__` for categorization inheritance?
The two parameters are `polymorphic_identity` and `polymorphic_on`. These help SQLAlchemy identify the subclass and the column that determines which subclass the record belongs to.
38
New cards
How does the `__init__` constructor work with the supertype’s constructor in inheritance?
The `__init__` constructor of a subclass calls the constructor of the superclass using `super()` to initialize inherited attributes.
39
New cards
How does the primary key of a category relate to its parent in inheritance?
The primary key of the category corresponds to the primary key of the parent because one instance of the parent class can only have one corresponding instance of the category class.
40
New cards
What is recursion in database design, and how is it handled in SQLAlchemy?
Recursion occurs when an entity has a relationship with itself, such as an employee managing other employees. In SQLAlchemy, this can be handled using self-referencing foreign keys.
41
New cards
What is **PyMongo** and how is it used with MongoDB?
PyMongo is the official Python driver for MongoDB, allowing interaction with MongoDB databases from Python applications.
42
New cards
What are the **fixtures** in Pytest?
Fixtures in Pytest are used to set up some initial conditions (such as a database or mock data) before a test function runs.
43
New cards
What does the `update_many()` method in MongoDB do?
The `update_many()` method updates all documents in a collection that match the query criteria. It can modify multiple documents at once.
44
New cards
What does the `$addToSet` operator do in MongoDB?
The `$addToSet` operator ensures that an item is added to an array only if it is not already present, avoiding duplicates.
45
New cards
What is the **One-to-Many** relationship in MongoDB?
A One-to-Many relationship occurs when one document is associated with multiple documents in another collection. The related documents are typically embedded or referenced.
46
New cards
What does the code `{'$addToSet': {'piece_parts': {'part_number': part_number}}}` do in a One-to-Many relationship in MongoDB?
This code adds a `piece_part` to the `piece_parts` array of the `suppliers` collection, ensuring that each part number is unique in that array.
47
New cards
What is the **Many-to-Many** relationship in MongoDB?
A Many-to-Many relationship occurs when multiple documents in one collection can be associated with multiple documents in another collection, often using an intermediary collection.
48
New cards
What constraints does MongoDB enforce in a Many-to-Many relationship?
MongoDB does not enforce constraints like SQL databases. You would typically implement application-level checks to ensure data integrity.
49
New cards
What is **MongoDB Inheritance** and how is it used?
MongoDB Inheritance allows a document structure to inherit fields from a parent document, enabling more flexible data models for hierarchical data.
50
New cards
How is **MongoDB Recursion** implemented?
MongoDB recursion can be implemented by embedding a document inside itself or by using references to represent hierarchical relationships between documents.
51
New cards
What is the **Data Life Cycle** in transactions?
The Data Life Cycle refers to the stages through which data moves: creation, storage, processing, and eventual deletion.
52
New cards
What are the phases in the **Data Life Cycle**?
The phases typically include data collection, data storage, data processing, and data deletion. Each phase is crucial for ensuring the data's validity and integrity over time.
53
New cards
What are the four letters in **ACID** and what do they stand for?
**ACID** stands for Atomicity, Consistency, Isolation, and Durability, ensuring database transactions are processed reliably.
54
New cards
What is **transaction isolation** and what does it provide?
Transaction isolation ensures that transactions are executed in a way that prevents data anomalies, such as dirty reads, non-repeatable reads, and phantom reads.
55
New cards
What happens to updates within a transaction when it is **committed**?
When a transaction is committed, all updates made during the transaction are saved permanently to the database.
56
New cards
What are the four **transaction isolation levels**?
The four isolation levels are **Read Uncommitted**, **Read Committed**, **Repeatable Read**, and **Serializable**.
57
New cards
What anomalies can occur at each isolation level?

- **Read Uncommitted**: Dirty reads (uncommitted data)

- **Read Committed**: Non-repeatable reads

- **Repeatable Read**: Phantom reads

- **Serializable**: No anomalies (highest level of isolation).

58
New cards
What is the **Two-Phase Locking Protocol**?
Two-phase locking is a concurrency control method that guarantees serializability by requiring transactions to acquire locks before making changes and releasing them after the transaction is complete.
59
New cards
What are the three variations of **Two-Phase Locking**?
The three variations are **Strict 2PL**, **Rigorous 2PL**, and **Basic 2PL**. They differ in when locks are released during the transaction.
60
New cards
How many disks can go down in a **triple mirrored array** before you lose the whole array?
In a triple mirrored array (RAID 1), up to two disks can fail before the array is completely lost.
61
New cards
How many disks can go down in **RAID 4** before data is lost?
In RAID 4, one disk can fail without losing data, as the parity data is stored on a separate disk.
62
New cards
What is the difference between **savepoints** and **commit** in transactions?
A **savepoint** allows partial rollbacks to a specific point in a transaction, whereas **commit** permanently saves all changes made during the transaction.
63
New cards
What is the **Read Uncommitted** isolation level?
Allows transactions to read uncommitted data, leading to dirty reads.
64
New cards
What is a **dirty read**?
A **dirty read** occurs when a transaction reads data that has not been committed yet.
65
New cards
What anomaly is associated with **Read Uncommitted**?
**Dirty reads**.
66
New cards
What is the **Read Committed** isolation level?
Allows transactions to read only committed data, preventing dirty reads but allowing non-repeatable reads.
67
New cards
What is a **non-repeatable read**?
A **non-repeatable read** happens when a transaction reads the same data twice, and the data changes between reads.
68
New cards
What anomaly is associated with **Read Committed**?
**Non-repeatable reads**.
69
New cards
What is the **Repeatable Read** isolation level?
Prevents non-repeatable reads but allows phantom reads.
70
New cards
What is a **phantom read**?
A **phantom read** occurs when the result set of a query changes because another transaction inserted or deleted rows.
71
New cards
What anomaly is associated with **Repeatable Read**?
**Phantom reads**.
72
New cards
What is the **Serializable** isolation level?
Ensures no anomalies by making transactions behave as if executed sequentially.
73
New cards
What anomaly is associated with **Serializable**?
No anomalies.
74
New cards
What isolation level does **PostgreSQL** use by default?
**Read Committed**.
75
New cards
What does **Read Committed** in PostgreSQL allow?
It prevents dirty reads but allows non-repeatable reads.
76
New cards
What is the **SET TRANSACTION ISOLATION LEVEL** command used for in PostgreSQL?
It changes the isolation level of a transaction, such as to **Serializable** or **Repeatable Read**.
77
New cards
What is the **highest isolation level** in PostgreSQL?
**Serializable**.