We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6
ASSIGNMENT
ON
DATA BASE SYSTEM
Submitted To: Sir. Zahid Sb
Submitted By: ShairZaman Khan
Program Title: BS Computer Science (2021—2025)
Semester: 4th
PUNJAB GROUP OF COLLEGES
JAMPUR Primary key: A primary key is a candidate key that is selected by the database designer to the tuples uniquely in a relation. A relation may contain many candidate keys. When designer selects one of them to identify a tuple in the relation, it becomes a primary means that if there is only one candidate key, it will be automatically selected as primary. Some most important points about a primary key are: • A relation can have only one primary key. • Each value in primary key attribute must be unique. • Primary key cannot contain null values. Roll No Name Address 1 Ali Faisalabad 2 Ahmad Lahore 3 Nadeem Peshawar Roll No is an Primary Key: Composite key: A composite key is a primary key that consists of two or more columns in a table. It is used when no single attribute can uniquely identify a row, but a combination of attributes can. Here's an example of a table with a composite key:
Roll No Subject Marks
1 English 52 1 Math 77 1 Computer 64 2 English 58 2 Math 69 2 Computer 49 3 English 82 3 Math 98 3 Computer 86 Roll No and Subject are both Composite Primary Key: Alternate Key: The candidate keys that are not selected as primary key are known as alternate keys. Suppose student relation contains different attributes such as Reg No, Roll No, Name & Class. The attributes Reg No and Roll No can be used to identify each student in the table. If Reg No is selected as primary key then Roll No attribute is known as alternate key. Reg No Roll No Name Class
10 1 Nadeem Khalil MSc
20 2 M.Usman BSc
30 3 Noman Qadir FSc
Reg No primary key
Roll No alternate key Foreign Key: A foreign key is an attribute or set of attributes in a relation whose values match an primary key in another relation. The relation in which foreign key is created is known dependent table or child table. The relation to which the foreign key refers is known as parent table. The key connects to another relation is established b/w two relations. A relation may contain many foreign keys. The following figures shows two relations. The Roll No attribute in parent relation used as primary key. The Roll No attribute in child relation is used as foreign key. It refers Roll No attribute in parent relation. Table # 01 is Parent Table: Roll No Name Address
1 Nadeem Khalil Faisalabad
2 M.Usman Lahore
3 Noman Qadir Peshawar
Table # 02 is Child Table:
Roll No Subject Marks 1 English 52 1 Math 77 1 Computer 64 2 English 58 2 Math 69 2 Computer 49 3 English 82 3 Math 98 3 Computer 86
Complete Download (Ebook) Head First SQL: Your Brain on SQL -- A Learner's Guide (Head First) by Lynn Beighley ISBN 9780596526849, 0596526849 PDF All Chapters