0% found this document useful (0 votes)
12 views12 pages

Lecture 14 Sem I 2025

The document outlines various concepts related to database systems, including the definition and examples of associative entities, relational keys, and E-R diagrams. It discusses primary keys, candidate keys, and super keys, emphasizing their roles in uniquely identifying records in a database. Additionally, it provides scenarios for drawing E-R diagrams related to chemists, projects, and university courses.

Uploaded by

khanbisma584
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views12 pages

Lecture 14 Sem I 2025

The document outlines various concepts related to database systems, including the definition and examples of associative entities, relational keys, and E-R diagrams. It discusses primary keys, candidate keys, and super keys, emphasizing their roles in uniquely identifying records in a database. Additionally, it provides scenarios for drawing E-R diagrams related to chemists, projects, and university courses.

Uploaded by

khanbisma584
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

Database systems

Lecture 14
Previous Lecture Contents

• Associative Entities
• Example
• Ternary relationship as an associative entity

2
Lecture Outline
• ER scenario

3
Draw an E-R diagram for each of the following situations:
a.A laboratory has several chemists who work on one or more projects.
b.Chemists also may use certain kinds of equipment on each project.
c. Attributes of CHEMIST include Employee_ID (identifier), Name, and Phone_No.
d.Attributes of PROJECT include Project_ID (identifier) and Start_ Date.
e.Attributes of EQUIPMENT include Serial_No and Cost.
f.The organization wishes to record Assign_Date—that is, the date when a given equipment
item was
assigned to a particular chemist working on a specified project.
a.A chemist must be assigned to at least one project and one equipment item.
b.A given equipment item need not be assigned, and a given project need not be assigned
either a chemist or an equipment item.
c.Provide good definitions for all of the relationships in this situation

4
Draw an E-R diagram for each of the following situations:
a.A university has large number of courses in its catalog.
b.Attributes of COURSE include Course-number (identifier), Course-Name, and credit-
hours.
c.Each course may have one or more different courses as prerequisites, or may have no
prerequisites.
d.Similarly, a particular course may be a prerequisite for any number of courses, or may not
be a prerequisite for any other course.

5
Relational keys

Relational keys are used during the systems design phase to organize, access,
and maintain data structures. The four types of key fields are primary keys,
candidate keys, foreign keys, and secondary keys.

6
Relational keys
Primary key: A field or combination of fields that uniquely and minimally
identifies a particular member of an entity. An identifier may be ‘artificial,’
such as creating an ID number.

For example, in a student table the student number is a unique primary key
because no two students can have the same student number. That key also is
minimal because it contains no information beyond what is needed to
identify the student.

Sometimes it is necessary for a primary key to consist of a combination of


fields. In that case, the primary key is called a combination key, composite
key, concatenated key, or multi-valued key.

For example, if a student registers for three courses, his or her student
number will appear in three records so its no more valid as a primary key. So
in the registration file, neither the student number nor the course ID is
unique, to identify a specific student in a specific course, the primary key
must be a combination of student number and course ID

7
8
Relational keys
• Key Fields
• Super key: A superkey is a set of attributes within a table whose values can be used to
uniquely identify a tuple.

• A candidate key is a minimal set of attributes necessary to identify a tuple

• This is also called a minimal superkey.

• Given an employee schema consisting of the attributes employeeID, name, job, and
departmentID, where no value in the employeeID attribute is ever repeated, we could use
the employeeID in combination with any or all other attributes of this table to uniquely
identify a tuple in the table.

• Examples of superkeys in this schema would be {employeeID, Name}, {employeeID,


Name, job}, and {employeeID, Name, job, departmentID}.

• The last example is known as trivial superkey, because it uses all attributes of this table to
identify the tuple.

9
Super Key

• A super key is a set of one or more columns that can uniquely identify
records, but it may contain more columns than necessary.
• For instance, the combination of (StudentID, Email, Date of Birth)
can be considered a super key because it can uniquely identify
students in the table. However, it includes more columns than the
minimum required for uniqueness.

StudentID SSN Email Student Name Date of Birth Phone Number


1 123-45-6789 [email protected] John Smith 1995-03-15 555-123-4567
2 987-65-4321 [email protected] Sarah Brown 1998-08-22 555-987-6543
3 456-78-9012 [email protected] Mike Johnson 1997-05-10 555-789-0123
4 789-01-2345 [email protected] Emily White 1996-12-03 555-234-5678
5 234-56-7890 [email protected] Chris Davis 1999-02-28 555-345-6789

10
Candidate Key

• A candidate key is a set of one or more columns that can uniquely identify each
record in a table.
• In our "Students" table, the Social Security Number (SSN) can serve as a
candidate key because it uniquely identifies each student. No two students have
the same SSN, making it a candidate key.
• Another candidate key in this example could be a combination of columns, such
as (Email, Date of Birth), as this combination is also unique for each student.

StudentID SSN Email Student Name Date of Birth Phone Number


1 123-45-6789 [email protected] John Smith 1995-03-15 555-123-4567
2 987-65-4321 [email protected] Sarah Brown 1998-08-22 555-987-6543
3 456-78-9012 [email protected] Mike Johnson 1997-05-10 555-789-0123
4 789-01-2345 [email protected] Emily White 1996-12-03 555-234-5678
5 234-56-7890 [email protected] Chris Davis 1999-02-28 555-345-6789

11
Primary Key

• A primary key is a specific candidate key chosen by the database


designer to be the main unique identifier for records in a table.
• In our "Students" table, the StudentID column is chosen as the
primary key. This means that StudentID will be the primary means of
uniquely identifying each student record.
• The primary key must have unique values for each record and cannot
contain NULL values. In this case, StudentID meets these criteria and
serves as the primary key.

StudentID SSN Email Student Name Date of Birth Phone Number


1 123-45-6789 [email protected] John Smith 1995-03-15 555-123-4567
2 987-65-4321 [email protected] Sarah Brown 1998-08-22 555-987-6543
3 456-78-9012 [email protected] Mike Johnson 1997-05-10 555-789-0123
4 789-01-2345 [email protected] Emily White 1996-12-03 555-234-5678
5 234-56-7890 [email protected] Chris Davis 1999-02-28 555-345-6789
12

You might also like