Database Keys and Attributes Flashcards

1
Q

Name the types of keys in DBMS (7).

A
  1. Primary key
  2. Candidate key
  3. Super key
  4. Foreign key
  5. Alternate key
  6. Composite key
  7. Artificial key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Primary key?

A

The first unique and non-null key used to identify one and only one instance of an entity. It is selected by the database designer while designing the database.

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

What is Candidate key (CK)?

A

A candidate key is an attribute or minimal set of attributes that can uniquely identify a tuple. Some of the candidate key columns can have a null value.

For example: In the EMPLOYEES table, id is best suited for the primary key. The rest of the attributes, like SSN, Passport_Number, and License_Number are considered a candidate key.

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

What is Super key?

A

Super key is an attribute set that can uniquely identify a tuple. A super key is a superset of a candidate key.

For example: In the EMPLOYEES table the name of two employees can be the same, but their EMPLOYEE_ID cannot. Hence, this combination can also be a super key.

The super key would be EMPLOYEE-ID (EMPLOYEE_ID, EMPLOYEE-NAME).

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

What is Foreign key?

A

Foreign keys are the column of the table used to point to the primary key of another table.

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

What is Alternate key?

A

There may be one or more attributes or a combination of attributes that uniquely identify each tuple in a relation. These attributes or combinations of the attributes are called the candidate keys. One key is chosen as the primary key from these candidate keys, and the remaining candidate key, if it exists, is termed the alternate key.

In other words, the total number of the alternate keys is the total number of candidate keys minus the primary key. The alternate key may or may not exist. If there is only one candidate key in a relation, it does not have an alternate key.

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

What is Composite key?

A

A primary key, but as a combination of two or more columns in a table that can be used to uniquely identify each row in the table.

Uniqueness is only guaranteed when the columns are combined; when taken individually the columns do not guarantee uniqueness.

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

What is Artificial key?

A

The key created using arbitrarily assigned data. These keys are created when a primary key is large and complex and has no relationship with many other relations. The data values of the artificial keys are usually numbered in a serial order.

For example, the primary key, which is composed of Emp_ID, Emp_role, and Proj_ID, is large in employee relations. So it would be better to add a new virtual attribute to identify each tuple in the relation uniquely.

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

What is an attribute?

A

A property or characteristics of an entity.

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

What is entity?

A

A living or non-living object.

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

What is a tuple?

A

One record (one row).

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

What is Non-prime / Non-key attribute?

A

A column which can not be used to identify a record uniquely, for example, name or age columns in the customers table.

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

Name 5 different types of attributes.

A

Simple, Composite, Single-Valued, Multi-Valued, Derived.

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

What is a simple attribute (with an example)?

A

An atomic attribute that cannot be further subdivided into components.

Example: the roll number of a student, the ID of an employee.

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

What is a single-valued attribute (with an example)?

A

The attribute that takes up only a single value for each entity instance.

Example: The age of a student.

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

What is a composite attribute (with an example)?

A

An attribute that can be split into components.

Example: The address can be further split into house number, street number, city, state, country, and pin code, the name can be also split into first and last name.

17
Q

What is a multi-valued attribute (with an example)?

A

The attribute that takes up more than a single value for each entity instance.

Example: Phone number of a student (landline and mobile).

18
Q

What is a derived attribute (with an example)?

A

An attribute that can be derived from other attributes.

Example: Total and average marks of a student.