Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»7 Different Types of Keys in DBMS

    7 Different Types of Keys in DBMS

    June 8, 2024

    The key is unique for every lock. Similarly, those attributes which are unique for every entity in a single table, are known as key attributes. Keys are nothing else only the unique attributes associated with every entity.

    Keys are useful in dbms for various reasons such as data integrity, efficient data retrieval, data consistency, data sorting, and many more. Let’s have a look at the different types of keys available in DBMS.

    Candidate Key

    Those attributes which may be unique for an entity can be considered as Candidate keys. Like ID, name, mobile number, and address in the above table.

    Primary Key

    From candidate keys, we choose a key that is almost unique for every entity, called the Primary key for that entity and the whole table. Name, address, and mobile number may be not unique, but the ID number will be unique for every entity, so we choose the ID number as a primary key.

    The primary keys should be easy to find, and allocate, and not be much complex.

    Mobile numbers are also unique for every entity, but mobile number contains at least a 12-digit string, which is quite complex and lengthy for rapid use, so we can’t use it as a Primary key. Instead of this the ID number may be shorter and follow a fixed sequence, easy to generate and allocate, that’s why we should use the ID number as a Primary key.

    Alternate Key

    After selecting our primary key, the remaining candidate keys are considered as Alternate keys. Which may be used at the place of primary key in any specific situation.

    Foreign Key

    When we use the primary key to join tables, then we need to put the primary key in every table. In the main table, it is considered as a Primary key but in other tables, it is considered as a foreign key. Like in the above table “Employee”, the ID number is the Primary key, but if we use it in any other table of the database, then it is considered as a foreign key, and those other tables also have their own primary key as well. Primary key and foreign key concept is used to connect tables.

    Composite Key

    When we merge two or more candidate keys to create a more powerful or unique key for any entity or table then it is known as a composite key, but the primary key should be part of the composite key. Sometimes we can use any ordinary attribute to merge with a primary key to create a composite key.

    Super Key

    Sometimes only one primary key is not enough to maintain uniqueness for an entity, in that case, we merge the primary key with any one or more than one alternate key to create a module of the primary key, then this is known as a super key.

    Like “ID + Email = Super key”.

    In this case for every entity ID and Email both the attributes must be unique. If any one of them may not be unique then the entity will not be taken in the table.

    Unique Key

    Primary keys never accept NULL values. So, if we want to make any attribute a primary key with NULL values then this key will be called a Unique key. Most of the time Unique key is created by merging two or more alternate keys. In which the Primary key should not be null but the other alternate key may contain Null Value.

    Like “ID + Email = Unique key”.

    In this, the ID is a primary key and can allow a Null value, but the Email may hold a Null value.

    NULL: This is a keyword, that shows the table that in this tuple or block no value is given, so at run time show this block as blank. We can’t leave any tuple or block blank, otherwise, the whole data set will be rejected, so in the blank place, we may put NULL.

    The post 7 Different Types of Keys in DBMS appeared first on The Crazy Programmer.

    Source: Read More

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleMac vs Windows for Programming
    Next Article A World Without Space: AI’s Final Solution in 2679

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 17, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4831 – TOTOLINK HTTP POST Request Handler Buffer Overflow Vulnerability

    May 17, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Advanced API Testing Part 2: JSON Schema Validation, Serialization & Deserialization Techniques

    Development

    CVE-2025-3471 – “SureForms WordPress Plugin Unauthenticated Configuration Update”

    Common Vulnerabilities and Exposures (CVEs)

    Easily Check the Responsiveness of Your Wix Studio Website with Pixefy

    Development

    AutoDroid-V2: Leveraging Small Language Models for Automated Mobile GUI Control

    Development

    Highlights

    How to Run more than 1 Query through JMeter to do load testing

    June 11, 2024

    I got a job to do load testing on database. The problem is I have 3 queries that need to run one after another to get the result as below sequence.

    UPDATE db_swim_dev.ios_upgrade_css_site_selection SET
    pre_check=’PROCESSING’ WHERE id=’Dynamic Value need to fetch
    from CSV’;
    INSERT INTO db_swim_dev.tbl_ios_css_checks (id, hostname,
    r0_state, r1_state, device_type, version, issu_ready,
    licence_advancedmetroipaccess, licence_status, device_model,
    software_state, cust_special, power_state, fan_state,
    output, ios_image_update, job_id, site_master_id, rcount,
    mmcblk0) VALUES (”, ‘dynamic value need to fetch from CSV’, ”,
    ”, ‘920o’, ‘V156_2_SP_SR680887239_8’, ‘0’, ‘0’, ‘1’, ‘0’, ‘0’, ‘0’,
    ‘0’, ‘0’,
    ‘a:3:{s:11:”device_type”;s:4:”920o”;s:14:”licence_status”;i:1;s:7:”mmcblk0″;i:0;}’,
    ‘0’, ‘246’, ‘19442’, ‘0’, ‘0’);
    UPDATE db_swim_dev.ios_upgrade_css_site_selection SET
    pre_check=’FAILED’ WHERE id=’Dynamic value need to fetch from
    CSV’;

    I am not sure how to do that. I tried to run all the queries together getting an error. If anyone has encountered the same scenario please let me know how to make this work.

    How does Data Engineering in Retail Maximize Efficiency?

    May 30, 2024

    Microsoft, Ivanti, and More: 2024 KEV Catalog Highlights Vendor Vulnerabilities

    December 30, 2024

    New generative media models and tools, built with and for creators

    May 14, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.