Creating Payment Microservice, Cron and Webhooks Flashcards

1
Q

What is the Repository Pattern?

A

The Repository Pattern is a design pattern that abstracts the logic for data access and manipulation, providing a consistent interface for accessing data regardless of the actual data source.

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

What is the purpose of the Repository Pattern?

A

The main purpose is to centralize and isolate the logic for data access, allowing the rest of the application to interact with data through a uniform interface, enhancing testability and maintainability.

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

How does the Repository Pattern work?

A

It provides an intermediary layer between the application and the data source, containing methods for querying, adding, updating, and deleting data without exposing the underlying data access details.

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

What are the key components of the Repository Pattern?

A

Components include:

Interface: Defines the contract for data access methods.
Implementation: Provides the concrete implementation of these methods.
Data Source: The actual storage or database where data is retrieved or manipulated.

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

What benefits does the Repository Pattern offer?

A

Benefits include:

Abstraction: Hides complexities of data access logic.
Centralization: Provides a single point of entry for data operations.
Testability: Allows easy mocking for unit tests.
Flexibility: Allows for swapping data sources without affecting the application logic.

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

Is the Repository Pattern specific to certain programming languages or frameworks?

A

No, the pattern can be implemented in various programming languages and frameworks as a way to abstract data access logic.

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

When is the Repository Pattern particularly useful in software development?

A

It’s useful in applications where there are multiple data sources or when there’s a need for a clean separation between business logic and data access logic.
The Repository Pattern serves as a valuable architectural pattern for managing data access logic, promoting modularity, maintainability, and flexibility in software development.

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

What is a UUID?

A

A UUID (Universally Unique Identifier) is a 128-bit identifier used to uniquely identify information or objects in computer systems.

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

How is a UUID represented?

A

It is commonly represented as a 32-character hexadecimal string separated by hyphens, organized in five groups: 8-4-4-4-12 characters.

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

What are the characteristics of a UUID?

A

UUIDs are designed to be unique across time and space, generated using algorithms that ensure extremely low probability of collisions.

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

Why are UUIDs used in software development?

A

They are used to uniquely identify entities or resources, avoiding conflicts in distributed systems and providing a reliable way to reference information.

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

Can UUIDs be generated in different versions?

A

Yes, UUIDs can be generated in several versions (such as Version 1 to Version 5) based on different algorithms and input parameters.

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

What are the commonly used versions of UUIDs?

A

Common versions include:

Version 1: Based on time and MAC address.
Version 4: Generated from random or pseudo-random numbers.
Version 5: Using a hash of a namespace and name.

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

In what scenarios are UUIDs particularly useful?

A

UUIDs are beneficial in distributed systems, databases, or when creating unique identifiers without relying on centralized generation.

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

Are UUIDs always guaranteed to be unique?

A

While UUIDs are designed to be highly unique, the possibility of collisions is extremely low but not impossible, especially when using certain versions or inadequate generation methods.

UUIDs serve as reliable and widely adopted identifiers, ensuring uniqueness across systems and applications, contributing to the integrity and scalability of software systems.

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

What is a Mapped Superclass in JPA?

A

A Mapped Superclass is a class annotated with @MappedSuperclass in JPA that contains persistent state and mappings but isn’t mapped to a specific database table.

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

What’s the purpose of a Mapped Superclass?

A

It provides reusable mappings and fields shared among multiple entity classes, avoiding code duplication and ensuring consistent mapping logic across entities.

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

How does a Mapped Superclass differ from a regular entity in JPA?

A

A Mapped Superclass cannot be queried independently as it’s not an entity itself. Instead, its attributes and mappings are inherited by entities that extend it.

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

Can instances of a Mapped Superclass be persisted to the database?

A

No, instances of a Mapped Superclass cannot be directly persisted. Only entities that inherit from the Mapped Superclass can be persisted.

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

What annotations are commonly used with a Mapped Superclass?

A

Annotations like @MappedSuperclass, @Column, @Id, @GeneratedValue, and others can be used within the Mapped Superclass to define shared mappings and properties.

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

Why is a Mapped Superclass useful in JPA?

A

It promotes code reusability, allowing developers to define common attributes, relationships, or mapping configurations in a central place that can be inherited by multiple entities.

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

Can a Mapped Superclass be abstract or concrete?

A

Yes, a Mapped Superclass can be either abstract (providing only the structure) or concrete (with implementations for methods).

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

When is it appropriate to use a Mapped Superclass?

A

It’s beneficial when multiple entities share common attributes or mappings that should be defined in one place to maintain consistency and avoid redundancy.

Mapped Superclasses in JPA offer a convenient way to manage shared attributes and mappings among entities, enhancing code organization and maintainability in database-driven applications.

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

What is a joined table in database terminology?

A

A joined table is a virtual table created by combining rows from two or more tables using SQL JOIN operations based on related columns.

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

How is a joined table created?

A

It’s created using SQL JOIN statements, specifying the tables to join and the join conditions (e.g., INNER JOIN, LEFT JOIN, RIGHT JOIN) based on common columns.

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

What’s the purpose of a joined table?

A

It allows for querying data from multiple tables simultaneously, retrieving related information, and presenting it in a single result set based on specific join conditions.

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

What types of JOIN operations are commonly used to create joined tables?

A

Common JOIN types include:

INNER JOIN: Returns rows that have matching values in both tables.
LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and the matched rows from the right table.
RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table and the matched rows from the left table.

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

What are the benefits of using joined tables?

A

Joined tables allow for efficient retrieval of related data, reduce data redundancy, and support complex queries involving multiple tables.

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

Can joined tables contain data permanently stored in the database?

A

No, a joined table is a temporary or virtual representation of combined data from multiple tables based on a specific query, and it doesn’t physically exist in the database.

30
Q

How are columns accessed in a joined table?

A

Columns in a joined table are accessed using their table aliases or fully qualified names to avoid ambiguity when columns have the same names in different tables.

31
Q

What considerations should be made when using joined tables?

A

Efficient indexing, appropriate use of JOIN types, understanding relationships between tables, and optimizing queries are crucial for optimal performance.

Joined tables play a pivotal role in relational databases, enabling the retrieval and presentation of related data across multiple tables through SQL JOIN operations, facilitating complex data retrieval and analysis.

32
Q
A
33
Q

What are the impacts of changing a primary key value in a database?

A

Referential Integrity: Changing a primary key value can disrupt referential integrity if the key is referenced by foreign keys in other tables.

Data Consistency: If the primary key is being updated, all related foreign key references must be updated to maintain data consistency.

Performance Impact: Frequent updates of primary key values can impact performance due to index maintenance and potential table reorganization.

Database Locks: Depending on the database system, updating primary key values might cause locks, affecting concurrent operations.

Historical Records: If historical records or audit trails rely on primary key values, changing them might affect the accuracy of historical data.

Complexity and Risk: Changing primary key values often requires careful planning and execution to avoid data loss or corruption.

34
Q

Are there alternatives to changing primary key values directly?

A

Yes, alternatives include using surrogate keys that are independent of the data (e.g., auto-incremented IDs) or implementing unique business identifiers alongside primary keys.

35
Q

What are the advantages of using a string as a primary key?

A

Meaningful IDs: Strings can represent natural identifiers that are more human-readable and meaningful than numeric IDs.
Data Integration: String-based primary keys can align with external systems or datasets using similar string identifiers.
Simplicity: Using strings as keys might eliminate the need for additional surrogate keys, simplifying the data model.

36
Q

Can a string be used as a primary key in a database?

A

Yes, a string can serve as a primary key in a database, typically defined as a VARCHAR or TEXT column.

37
Q

Are there any drawbacks to using strings as primary keys?

A

Performance: String comparisons might be slower than numeric comparisons, impacting performance in large datasets.
Index Size: String-based indexes can be larger and may affect index performance.
Uniqueness: Ensuring uniqueness with strings can be complex, especially if the natural identifier isn’t inherently unique.

38
Q

What considerations should be made when using strings as primary keys?

A

Length Limit: Define an appropriate length for the string to balance readability and index performance.
Normalization: Ensure the string key values are normalized and consistent to avoid redundancy.
Uniqueness: Implement mechanisms (like constraints or validation rules) to ensure uniqueness of string-based keys.

39
Q

When is it suitable to use strings as primary keys?

A

Strings as primary keys are suitable when dealing with entities having natural identifiers or when business requirements prioritize meaningful identifiers over surrogate keys.

40
Q

What potential security threats are associated with using auto-incremented public IDs in applications?

A

Information Disclosure: Sequential IDs can reveal patterns, exposing data creation frequency or volume.
Enumeration Attacks: Predictable IDs enable attackers to systematically iterate through records.
Data Scraping and Brute-Force: Automated scripts can scrape data or launch brute-force attacks.
Direct Object Reference (DOR) Vulnerabilities: Manipulating IDs might grant unauthorized access to resources.

41
Q

How can information disclosure be a risk with auto-incremented public IDs?

A

Sequential IDs might reveal the frequency of user activity or data creation, allowing attackers to infer sensitive information.

42
Q

What is an enumeration attack, and how is it related to predictable IDs?

A

Enumeration attacks involve systematically guessing or iterating through IDs to access other users’ data or resources, exploiting predictable ID sequences.

43
Q

How can auto-incremented public IDs lead to direct object reference vulnerabilities in web applications?

A

These IDs might be directly used in URLs or references, enabling attackers to manipulate them and access unauthorized resources.

44
Q

What strategies can mitigate security risks associated with auto-incremented public IDs?

A

Implement UUIDs or randomly generated IDs, robust access controls, encryption for sensitive data, rate limiting, and regular security audits to identify and address vulnerabilities.

45
Q

What challenges arise when using auto-incrementing primary keys in distributed databases?

A

Conflict Resolution: Multiple nodes generating their own auto-increment IDs may lead to conflicts and synchronization issues.
Coordination: Ensuring unique IDs across distributed nodes requires synchronization mechanisms.
Performance Impact: Centralized auto-increment IDs can become bottlenecks, impacting performance in distributed setups.

46
Q

How do distributed databases handle conflict resolution with auto-incrementing IDs?

A

Techniques include centralized ID generation, distributed algorithms (like UUIDs), or assigning ID ranges to specific shards/partitions.

47
Q

What is the impact of traditional auto-increment IDs in distributed systems using sharding or partitioning?

A

Assigning ID ranges to specific shards or partitions helps maintain uniqueness within each shard while reducing conflicts.

48
Q

What are the alternatives to traditional auto-increment IDs in distributed databases?

A

UUIDs or globally unique identifiers offer better scalability and reduce the likelihood of conflicts in distributed setups.

49
Q

How do consistency and synchronization play a role in managing auto-incrementing IDs in distributed systems?

A

Ensuring consistency and isolation levels across nodes is crucial to prevent data inconsistencies caused by concurrent operations on auto-incrementing IDs.

50
Q

What synchronization protocols can aid in managing distributed transactions and coordinating ID generation?

A

Distributed consensus protocols such as Paxos, Raft, or Distributed Lock Managers can assist in managing synchronization and coordination.

51
Q

What are hash algorithms?

A

Hash algorithms are cryptographic functions that take an input (data of any size) and produce a fixed-size output, known as a hash value or digest.

52
Q

What are the key properties of hash algorithms?

A

Deterministic: Same input always produces the same output hash.
Irreversibility: It’s computationally infeasible to reverse or recreate the input from the hash.
Fixed Output Size: Regardless of input size, hash algorithms produce a fixed-size output.
Avalanche Effect: A small change in input leads to a significantly different hash value.

53
Q

What are hash functions commonly used for?

A

Hash functions are used in cryptography, data integrity checks, password storage, digital signatures, and data indexing.

54
Q

Can you name some popular hash algorithms?

A

Common hash algorithms include MD5 (Message Digest Algorithm 5), SHA-1 (Secure Hash Algorithm 1), SHA-256, SHA-512, and others from the SHA-2 and SHA-3 families.

55
Q

What is the purpose of using hash algorithms in cryptography?

A

In cryptography, hash functions are used to create digital signatures, verify data integrity, and securely store passwords by generating hashes that are difficult to reverse-engineer.

56
Q

What is MD5?

A

MD5, which stands for Message Digest Algorithm 5, is a widely used cryptographic hash function that generates a 128-bit (16-byte) hash value from an input message of any length.

57
Q

What is inheritance in the context of a database?

A

In database design, inheritance refers to the concept of organizing data models to reflect relationships between entities, particularly in cases where one entity shares attributes with another but also has its unique attributes.

58
Q

What are the common strategies to represent inheritance in a database?

A

Three common strategies include:

Single Table Inheritance (STI)
Class Table Inheritance (CTI)
Concrete Table Inheritance (CTI)

59
Q

Explain Single Table Inheritance (STI) in database design.

A

STI involves storing all subclasses in a single table, sharing common attributes and adding specific columns for each subclass. It’s a straightforward approach but can lead to sparse tables with many null values.

60
Q

What is Class Table Inheritance (CTI) in database design?

A

CTI uses separate tables for each subclass, containing specific attributes unique to each subclass, along with a common table for shared attributes. This method provides cleaner normalization but might require complex queries.

61
Q

Describe Concrete Table Inheritance (CTI) in database design.

A

CTI involves creating separate tables for each subclass that contain both inherited and specific attributes, without a common superclass table. It allows for more flexibility but may result in redundancy.

62
Q

What factors should be considered when choosing an inheritance representation strategy in a database?

A

Considerations include the database schema complexity, query performance, data integrity, maintenance efforts, and the specific use case or application requirements.

63
Q

What is the “Table per Class Hierarchy” strategy in JPA?

A

The “Table per Class Hierarchy” strategy in JPA is an inheritance mapping strategy where all classes in an inheritance hierarchy are mapped to a single database table. Discriminator columns differentiate between different types of entities within this table.

64
Q

How does the “Table per Class Hierarchy” strategy store inheritance-related entities in the database?

A

All entities in the inheritance hierarchy, including their inherited and specific attributes, are stored in a single database table. A discriminator column is used to identify the type of each entity row.

65
Q

What are the advantages of the “Table per Class Hierarchy” strategy in JPA?

A

Advantages include a simplified database schema, reduced joins for queries involving the inheritance hierarchy, and fewer tables, leading to potentially better performance.

66
Q

What are some potential drawbacks of the “Table per Class Hierarchy” strategy in JPA?

A

Drawbacks include the possibility of having many nullable columns in the table, potential performance issues with large inheritance hierarchies, and difficulties in representing unrelated subclasses.

67
Q

How is the discriminator column used in the “Table per Class Hierarchy” strategy?

A

The discriminator column contains values that differentiate between different types of entities within the same table, enabling JPA to determine the specific subclass when fetching or persisting entities.

68
Q

What is the Single Table Inheritance (STI) strategy in JPA?

A

The Single Table Inheritance (STI) strategy in JPA is an inheritance mapping approach where all entities in an inheritance hierarchy are mapped to a single database table. Common and specific attributes of all subclasses are stored in this single table, differentiated by a discriminator column.

69
Q

What are the advantages of using the Single Table Inheritance (STI) strategy in JPA?

A

Simplicity: STI simplifies the database schema by using a single table for all entities in the inheritance hierarchy.
Reduced Joins: Queries involving the inheritance hierarchy typically require fewer joins since all data is in one table.
Performance: In certain scenarios with small to medium-sized hierarchies, STI can offer good performance.

70
Q

What are some limitations or considerations when using the Single Table Inheritance (STI) strategy in JPA?

A

Nullable Columns: STI may lead to many nullable columns in the table, especially for attributes specific to certain subclasses.
Data Redundancy: It can result in redundant data storage for subclass-specific attributes, even if they are not applicable to all rows.
Performance Challenges: With larger hierarchies or frequently changing subclasses, performance issues might arise due to nullable columns and increased table size.

71
Q

How is the discriminator column used in the Single Table Inheritance (STI) strategy?

A

The discriminator column contains values that differentiate between different types of entities within the single table. It helps JPA understand the specific subclass when retrieving or persisting entities.