what is primary key,unique key, foreign key? can u teach me
in simple language?

Answer Posted / pappu

The primary key of a relational table uniquely identifies
each record in the table. It can either be a normal
attribute that is guaranteed to be unique (such as Social
Security Number in a table with no more than one record per
person) or it can be generated by the DBMS (such as a
globally unique identifier, or GUID, in Microsoft SQL
Server). Primary keys may consist of a single attribute or
multiple attributes in combination

a unique key can uniquely identify each row in a table,
and is closely related to the Superkey concept. A unique
key comprises a single column or a set of columns. No two
distinct rows in a table can have the same value (or
combination of values) in those columns if NULL values are
not used. Depending on its design, a table may have
arbitrarily many unique keys but at most one primary key.

Unique keys do not enforce the NOT NULL constraint in
practice. Because NULL is not an actual value (it
represents the lack of a value), when two rows are
compared, and both rows have NULL in a column, the column
values are not considered to be equal. Thus, in order for a
unique key to uniquely identify each row in a table, NULL
values must not be used, however a column defined as unique
key column allows only one null value, which in turn can
uniquely identify that row/tuple.


A foreign key is a field (or fields) that points to the
primary key of another table. The purpose of the foreign
key is to ensure referential integrity of the data. In
other words, only values that are supposed to appear in the
database are permitted.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by database?

588


london school of science and technology has a software development unit,known as lsst solutions,which is responsible for developing and implementing software throughout the collegejames tristan keeps a record of all student details in the college including student id,name,and start date and phone number.There are many courses offered by LSST. For example MBA, MSc, BSc, BABS, DF, English etc. Each course id identified by course id, description, duration. Each course has many semesters. Each semester takes place during a particular term. Semester details and term details are required to be stored in the database. Each course has many subjects and same subject may be offered in many courses. For each subject many details such as Subject code, name, result and attendance are required to be stored. Every subject has mainly two assessments; one assignment and one exam. Assignment is worth of 30% and exam 70% respectively. You have been appointed as a database designer. Your job is to provide ERD with all possible entities and relationships. Note: Feel free to make necessary assumptions 3: Assignment Tasks. 1. Create an ERD for the above problem 2. Translate the ERD to Relational Data model (RDM) 3. Implement the RDM by creating the tables 4. Populate the database with your own data. 5. SQL Queries for the following tasks a. List all student details in each course along with course details b. Count and display number of students in each course. c. List student name, course name, assessment description, marks for all students.

2002


Can you create a database in word?

520


List the properties of a transaction.

636


Explain the field term used in database.

545






Can we use redis as database?

544


how can you perform lookup range in lookup stage expalin in detail?

1518


You are creating a Index on EMPNO column in the EMPLOYEE table. Which statement will you use?

779


WHAT IS CARDINALITIES OF JOIN?

1921


how to configure oracle 10g in java1.5 and tell me know how to set class path in system?

1581


Explain database partitioning.

633


What is the concept of Virtual field?

1614


How do you pass parameter in stored procedure?

727


What is difference between data and database?

550


Differentiate between unique key and foreign key?

580