SQL - 01 Flashcards

1
Q

What is the difference between a CPU Core and a CPU Thread?

A

A CPU core is the physical part of the CPU that performs the computing work. A thread, on the other hand, is a virtual component that manages tasks. Some CPUs use multi-threading to allow each core to handle multiple tasks simultaneously.

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

What is a CPU Core?

A

A CPU core is an individual processing unit within a computer’s central processing unit (CPU). It can independently execute computer instructions, allowing for more efficient processing of multiple tasks.

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

How does Multi-Core CPU differ from a Single-Core CPU?

A

A multi-core CPU has multiple cores, allowing it to perform multiple processes simultaneously, greatly improving performance over single-core CPUs, especially for multi-threaded applications.

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

What is a Virtual Core?

A

A virtual core, commonly known as a thread, is a subdivision of a physical CPU core. It allows a single core to execute multiple threads or tasks concurrently, enhancing the CPU’s multitasking capabilities.

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

How do Virtual Cores Work in CPUs?

A

Through a technology known as simultaneous multithreading (SMT), such as Intel’s Hyper-Threading, a single physical core is split into multiple virtual cores, allowing it to handle more than one instruction stream at a time.

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

What is the advantage of having Virtual Cores?

A

Virtual cores improve the efficiency of CPU resource utilization, allowing for better performance in multi-threaded applications and multitasking scenarios.

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

Do Virtual Cores double the performance of Physical Cores?

A

While virtual cores increase a CPU’s ability to handle multiple tasks, they do not double the performance. The performance gain depends on the nature of the tasks and the application’s ability to utilize multithreading.

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

How can you identify Virtual Cores in your system?

A

You can identify virtual cores in your system by checking the CPU specifications in the system settings or using system information tools. A CPU with SMT will show twice as many cores as the physical core count.

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

What is a Super Key?

A

A super key is a set of one or more columns (attributes) that can uniquely identify a record in a database table. It may contain additional attributes that are not necessary for unique identification.

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

What is a Primary Key?

A

A primary key is a specific type of super key. It’s a minimal set of columns that can uniquely identify each row in a table. Each table has a single primary key, and its values must be unique and not null.

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

What is a Unique Key?

A

A unique key is similar to a primary key in that it must contain unique values. The difference is that a table can have multiple unique keys, and unlike primary keys, they can contain null values (unless otherwise specified).

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

How is a Super Key different from a Primary Key?

A

While both super keys and primary keys uniquely identify records, super keys may contain additional attributes that aren’t necessary for uniqueness. A primary key is a minimal super key, meaning it has no unnecessary attributes.

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

When is a Unique Key used over a Primary Key?

A

A unique key is used when there is a need to enforce uniqueness on a column that is not the primary key. For instance, you might use it for a secondary identifier that must be unique, like an email address or employee ID.

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

What is a Candidate Key?

A

A candidate key is a set of one or more fields/columns in a table that can uniquely identify a record. Any candidate key can potentially become a primary key.

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

How does a Candidate Key differ from a Primary Key?

A

While both candidate and primary keys uniquely identify records in a table, the primary key is the chosen candidate key for that purpose. Other candidate keys become alternate keys.

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

Can a table have more than one Candidate Key?

A

Yes, a table can have multiple candidate keys, each capable of uniquely identifying a record. Only one of these is selected as the primary key.

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

What are the characteristics of a Candidate Key?

A

A candidate key must contain unique values and cannot have null values. Each value in the key must uniquely identify a row in the table.

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

Why is it important to identify Candidate Keys in a database?

A

Identifying candidate keys is important for ensuring data integrity and optimal database design. It helps in selecting the most suitable primary key and understanding data relationships.

19
Q

What is a Surrogate Key?

A

A surrogate key is an artificial or synthetic key used in a database table. It’s a unique identifier for each row that is not derived from application data.

20
Q

How is a Surrogate Key different from a Natural Key?

A

A surrogate key is system-generated, like an auto-incrementing number, whereas a natural key is derived from existing data attributes that are meaningful within the application context.

21
Q

Why are Surrogate Keys used in databases?

A

Surrogate keys are used because they provide a stable, unique identifier that doesn’t change as application data changes. They’re especially useful in complex databases with many relationships.

22
Q

What are the benefits of using a Surrogate Key?

A

Benefits include simplicity, as they are usually simple numeric values, and stability, since they are not affected by changes in application data. They also enhance performance in joins and queries.

23
Q

Can Surrogate Keys create any issues in database design?

A

While useful, surrogate keys can lead to an increase in space usage and might cause reliance on the database’s internal mechanism, making database portability more complex.

24
Q

What is a Foreign Key?

A

A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table. It’s used to establish and enforce a link between the data in two tables.

25
Q

How does a Foreign Key relate to a Primary Key?

A

The foreign key in one table points to a primary key in another table, creating a relational link. This ensures the referential integrity between the two tables.

26
Q

What is the purpose of a Foreign Key in a database?

A

The purpose of a foreign key is to maintain data integrity and allow navigation between two related tables in a database, ensuring that the relationships are valid and consistent.

27
Q

Can a Foreign Key contain null values?

A

Yes, a foreign key can contain null values. This indicates that the relationship is optional and the record in the referring table does not necessarily correspond to a record in the referenced table.

28
Q

What happens if data referenced by a Foreign Key changes or is deleted?

A

If data in the referenced table (with the primary key) changes or is deleted, it can affect the integrity of the foreign key. Database systems often use constraints to manage these situations, like ON DELETE CASCADE.

29
Q

What is a Junction Table?

A

A junction table, also known as a join table or bridge table, is used in a database to manage many-to-many relationships between two other tables. It contains foreign keys that reference the primary keys of the related tables.

30
Q

Why is a Junction Table needed?

A

In relational databases, a junction table is needed to efficiently manage many-to-many relationships, where each record in two different tables can relate to multiple records in the other table.

31
Q

What does a Junction Table typically contain?

A

A junction table typically contains foreign keys that reference the primary keys of the tables it joins. It may also contain additional fields that are relevant to the relationship.

32
Q

How does a Junction Table maintain data integrity?

A

By using foreign keys linked to the primary keys of the related tables, a junction table ensures referential integrity, meaning it maintains consistent and valid links between the related data.

33
Q

Can you give an example of a Junction Table?

A

Consider a database with ‘Students’ and ‘Courses’ tables. A junction table named ‘Enrollments’ can be used to link students to courses they enroll in. This table would include foreign keys referencing the primary keys of ‘Students’ and ‘Courses’.

34
Q

What is a Composite Primary Key?

A

A composite primary key is formed by using two or more columns in a table in combination to uniquely identify each row in the table. It’s used when no single column can uniquely identify the record.

35
Q

When is a Composite Primary Key used?

A

It’s used in scenarios where a combination of fields is required to ensure each record is uniquely identifiable. This is common in tables representing relationships between entities.

36
Q

How does a Composite Primary Key affect Database Design?

A

Using composite primary keys can make database designs more complex but allows for more accurate representation of real-world relationships and constraints.

37
Q

What are the considerations when using a Composite Primary Key?

A

Considerations include ensuring that the combination of columns is always unique and not null. Also, foreign key references to composite keys can be more complex.

38
Q

Can a Composite Primary Key be a Foreign Key in another Table?

A

Yes, a composite primary key can be referenced as a foreign key in another table. In such cases, all the columns of the composite key must be included in the foreign key reference.

39
Q

What is an Alternate Key?

A

An alternate key is a column or a set of columns in a database table that can uniquely identify each row in the table, just like a primary key. However, it is not chosen as the primary key.

40
Q

How does an Alternate Key differ from a Primary Key?

A

While both alternate and primary keys can uniquely identify records in a table, the primary key is the main key used for this purpose. An alternate key serves as a secondary option.

41
Q

Can a table have more than one Alternate Key?

A

Yes, a table can have multiple alternate keys, each capable of uniquely identifying records, but only one of these keys is chosen as the primary key.

42
Q

Why are Alternate Keys important in databases?

A

Alternate keys are important for ensuring data integrity and for providing additional unique identifiers for each record, which can be useful in various data operations and constraints.

43
Q

Are Alternate Keys always used in a database?

A

Not always. Their use depends on the specific requirements of the database design and the need for additional unique identifiers aside from the primary key.