Primary key,Candidate key,Alternate key,Foreign key | keys in DBMS

Primary key,Candidate key,Alternate key,Foreign key | keys in DBMS

 keys in DBMS foreign key, Primary key, Candidate key, Alternate key

keys in relational model in DBMS -it is important to be able to specify how rows in a relation are distinguished conceptually, rows are distinct from one another, but from a database perspective, the difference among them must be expressed in terms of their attributes. keys come here a rescue. We know that information uses tables to arrange info. to keep up knowledge integrity (that is knowledge ought to be correct and in we tend toll formed) we use thought of keys. There are unit 4 varieties of keys in information that Below describes –foreign key, Primary key, Candidate key, Alternate key.

Foreign key
primary key in SQL, Candidate key, Alternate key, Foreign key | keys in DBMS

Primary key in SQL (DBMS Primary key)

A primary key is a set of one or more attributes that can uniquely identify tuples within the relation. Within a given relation, a set of one or more attributes having values that sure are unique within relation and thus are able to uniquely identify that tuple is said to be the primary key in SQL of the relation.

Every relation does have a primary key in our sample database, SuppNo is the primary key in SQL suppliers as contains a unique value for each tuple in the relation. Similarly, an item is the primary key for an item and the combination of  SuppoNo and item No is a primary key for shipments relation.

In some tables, a combination of more than one attribute provides a unique value for each row. In such tables, a group of these attributes is declared as a primary key, in such cases, the primary key consists of more than one attribute, it is called composite-primary-key.

A primary key in SQL is nonredundant it does not have duplicate value in the same relation. The non-primary-key attributes of a table can be referred to as non-key attributes.

 Candidate key in DBMS (Candidate key in SQL)

All attribute combinations inside a relation that can serve as primary key are Candidate keys as they are Candidates for the primary key position. Occasionally we may encounter a relation in which there is more than one attribute possessing the unique identification property.

in our sample database, there are two candidate keys suppoNano and Supp-Name in Supplier’s relation. Both of these attributes contain unique values for each tuple.similarly, in items, item no and item-Name are candidate keys.

In the case of two or more candidate keys, only database analyst decides one of them as the primary for the relation.

Alternate key

A Candidate key that is not the primary key is called an Alternate key. In case of two or more candidate keys, only one of them serves as the primary key in SQL. The rest of them as they are alternates only.

In suppliers table, Supp_name is the alternate key and in items table, item_Name is the alternate key.

Foreign key (foreign key in SQL, foreign key in DBMS)

non-key attribute, whose value is derived from the primary key of some other table, is known as foreign-key in the current table. A foreign key is used to represent the relationship between two tables. a foreign key is a non-key attribute whose value is derived from the primary key of another table.or in other words, a non-key attribute of a table, which is the primary key of some other table is known as a foreign key in SQL.

The table in which this non-key attribute the foreign key attribute exists is called a foreign table or Detail table, and table that defines a primary key, which the foreign key in SQL of detail-table refers to, is called Primary table or Master table.

Read also Related article-

 what is MySQL server

Create MySQL database Community Server

what is Data Definition Language (DDL)? 

23 thoughts on “Primary key,Candidate key,Alternate key,Foreign key | keys in DBMS”

  1. hey there and thank you for your info ? I have
    definitely picked up anything new from right here. I did however expertise
    several technical issues using this site, as
    I experienced to reload the website lots of times previous
    to I could get it to load properly. I had been wondering if your web hosting is OK?
    Not that I am complaining, but sluggish loading instances times
    will sometimes affect your placement in google and
    can damage your quality score if ads and marketing with Adwords.
    Well I am adding this RSS to my e-mail and can look out for much more of your respective interesting content.
    Make sure you update this again very soon..

  2. Ich bin neugierig zu erfahren, wass blogggen platform Sie gerade sindd Arbeiten mit?
    Ich mit einige Mooll Sicherheit Probleme mitt meinem neuesten Website und Ich Ich würde erne etwas finden, mehr sicheres sichere.
    Haben Sie Lösungen?

  3. Thanks for some other informative web site. Where else may
    just I get that type of info written in such an ideal manner?
    I have a undertaking that I am just now operating on, and I have been on the
    glance out for such information.

  4. Sie haben einhige anständige Punkte gibt. Ich sah im Netz Weitere Informkationen über das Thema
    und fand die meisten Menschen wird gedhen zusammen mit Ihren Ansichten über diese Website.

  5. Icch habe Surfen Online- größer als dri 3 heute, aber
    I keineswegs entdeckte jede ibteressante Artikel wiie Ihres.
    Es ist schönen Wert genug ausreichend für mich. Meiner Meinung, wenn all Web-Besitzer und
    Bloggern aus guge Inhalt Material wiie Siie haben, ddie
    Web mss viel mehr hilfreich als je zuvor.

  6. Hallo, ich denke, dass ich sah, die Siie besucht mein weblog so i Ich bin “revanchieren”.

    Versuch zu zu finden, um die Dinge zu verbessern verbessern mein Website Ich
    nehmee an, es ist ok, um einie verwendn Ihre Ideen !!

  7. Hallo, Ordntlich Post. Es gibt Thema mit Website in Web explorer, Mai Test das?
    IE nch dennoch ist dder Markt Marktführer und eine große Element andere Leute werden weglassen Ihre great schriftlich durch diewes Problem.

  8. Hi there, just became aware of your blog through Google, and found
    that it is really informative. I am gonna watch out for brussels.
    I’ll appreciate if you continue this in future. Numerous people will be benefited from your writing.


  9. Hey, I think your blog might be having browser compatibility issues.

    When I look at your blog site in Safari, it looks fine but when opening in Internet Explorer, it
    has some overlapping. I just wanted to give you a quick heads up!
    Other then that, very good blog!

Leave a Comment