CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

08 April, 2022

Boyce Codd normal form

 Programing Coderfunda     April 08, 2022     DBMS     No comments   

Boyce Codd normal form (BCNF)

  • BCNF is the advance version of 3NF. It is stricter than 3NF.
  • A table is in BCNF if every functional dependency X → Y, X is the super key of the table.
  • For BCNF, the table should be in 3NF, and for every FD, LHS is super key.

Example: Let's assume there is a company where employees work in more than one department.

EMPLOYEE table:

EMP_IDEMP_COUNTRYEMP_DEPTDEPT_TYPEEMP_DEPT_NO
264IndiaDesigningD394283
264IndiaTestingD394300
364UKStoresD283232
364UKDevelopingD283549

In the above table Functional dependencies are as follows:

  1. EMP_ID  →  EMP_COUNTRY  
  2. EMP_DEPT  →   {DEPT_TYPE, EMP_DEPT_NO}  

Candidate key: {EMP-ID, EMP-DEPT}

The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.

To convert the given table into BCNF, we decompose it into three tables:

EMP_COUNTRY table:

EMP_IDEMP_COUNTRY
264India
264India

EMP_DEPT table:

EMP_DEPTDEPT_TYPEEMP_DEPT_NO
DesigningD394283
TestingD394300
StoresD283232
DevelopingD283549

EMP_DEPT_MAPPING table:

EMP_IDEMP_DEPT
D394283
D394300
D283232
D283549

Functional dependencies:

  1. EMP_ID   →    EMP_COUNTRY  
  2. EMP_DEPT   →   {DEPT_TYPE, EMP_DEPT_NO}  

Candidate keys:

For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}

Now, this is in BCNF because left side part of both the functional dependencies is a key.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Third Normal Form (3NF)

 Programing Coderfunda     April 08, 2022     DBMS     No comments   

 

Third Normal Form (3NF)

  • A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency.
  • 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
  • If there is no transitive dependency for non-prime attributes, then the relation must be in third normal form.

A relation is in third normal form if it holds atleast one of the following conditions for every non-trivial function dependency X → Y.

  1. X is a super key.
  2. Y is a prime attribute, i.e., each element of Y is part of some candidate key.
  3. Example:

    EMPLOYEE_DETAIL table:

    EMP_IDEMP_NAMEEMP_ZIPEMP_STATEEMP_CITY
    222Harry201010UPNoida
    333Stephan02228USBoston
    444Lan60007USChicago
    555Katharine06389UKNorwich
    666John462007MPBhopal

    Super key in the table above:

    1. {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on  

    Candidate key: {EMP_ID}

    Non-prime attributes: In the given table, all attributes except EMP_ID are non-prime.

    Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on EMP_ID. The non-prime attributes (EMP_STATE, EMP_CITY) transitively dependent on super key(EMP_ID). It violates the rule of third normal form.

    That's why we need to move the EMP_CITY and EMP_STATE to the new <EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.

    EMPLOYEE table:

    EMP_IDEMP_NAMEEMP_ZIP
    222Harry201010
    333Stephan02228
    444Lan60007
    555Katharine06389
    666John462007

    EMPLOYEE_ZIP table:

    EMP_ZIPEMP_STATEEMP_CITY
    201010UPNoida
    02228USBoston
    60007USChicago
    06389UKNorwich
    462007MPBhopal

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Second Normal Form (2NF)

 Programing Coderfunda     April 08, 2022     DBMS     No comments   

 

Second Normal Form (2NF)

  • In the 2NF, relational must be in 1NF.
  • In the second normal form, all non-key attributes are fully functional dependent on the primary key

Example: Let's assume, a school can store the data of teachers and the subjects they teach. In a school, a teacher can teach more than one subject.

TEACHER table

TEACHER_IDSUBJECTTEACHER_AGE
25Chemistry30
25Biology30
47English35
83Math38
83Computer38

In the given table, the non-prime attribute TEACHER_AGE is dependent on TEACHER_ID which is a proper subset of a candidate key. That's why it violates the rule for 2NF.

To convert the given table into 2NF, we decompose it into two tables:

TEACHER_DETAIL table:

TEACHER_IDTEACHER_AGE
2530
4735
8338

TEACHER_SUBJECT table:

TEACHER_IDSUBJECT
25Chemistry
25Biology
47English
83Math
83Computer

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

First Normal Form

 Programing Coderfunda     April 08, 2022     DBMS     No comments   

First Normal Form (1NF)

  • A relation will be 1NF if it contains an atomic value.
  • It states that an attribute of a table cannot hold multiple values. It must hold only The first single-valued attribute.
  • First normal form disallows the multi-valued attribute, composite attribute, and their combinations.

Example: Relation EMPLOYEE is not in 1NF because of the multi-valued attribute EMP_PHONE.

EMPLOYEE table:

EMP_IDEMP_NAMEEMP_PHONEEMP_STATE
14John7272826385,
9064738238
UP
20Harry8574783832Bihar
12Sam7390372389,
8589830302
Punjab

The decomposition of the EMPLOYEE table into 1NF has been shown below:

EMP_IDEMP_NAMEEMP_PHONEEMP_STATE
14John7272826385UP
14John9064738238UP
20Harry8574783832Bihar
12Sam7390372389Punjab
12Sam8589830302Punjab
    Read More
    • Share This:  
    •  Facebook
    •  Twitter
    •  Google+
    •  Stumble
    •  Digg

    Normalization

     Programing Coderfunda     April 08, 2022     DBMS     No comments   

     

    Normalization

    • Normalization is the process of organizing the data in the database.
    • Normalization is used to minimize the redundancy from a relation or set of relations. It is also used to eliminate, undesirable characteristics like Insertion, Update and Deletion Anomalies.
    • Normalization divides the larger table into the smaller table and links them using relationships.
    • The normal form is used to reduce redundancy from the database table.

    Types of Normal Forms

    There are the four types of normal forms:


    DBMS Normalization
    Normal FormDescription
    1NFA relation is in 1NF if it contains an atomic value.
    2NFA relation will be in 2NF if it is in 1NF and all non-key attributes are fully functional dependent on the primary key.
    3NFA relation will be in 3NF if it is in 2NF and no transition dependency exists.
    4NFA relation will be in 4NF if it is in Boyce Codd's normal form and has no multi-valued dependency.
    5NFA relation is in 5NF if it is in 4NF and does not contain any join dependency and joining should be lossless.
    Read More
    • Share This:  
    •  Facebook
    •  Twitter
    •  Google+
    •  Stumble
    •  Digg

    Inference Rule

     Programing Coderfunda     April 08, 2022     DBMS     No comments   

     

    Inference Rule (IR):

    • The Armstrong's axioms are the basic inference rule.
    • Armstrong's axioms are used to conclude functional dependencies on a relational database.
    • The inference rule is a type of assertion. It can apply to a set of FD(functional dependency) to derive other FD.
    • Using the inference rule, we can derive additional functional dependency from the initial set.

    The Functional dependency has 6 types of inference rule:

    1. Reflexive Rule (IR1)

    In the reflexive rule, if Y is a subset of X, then X determines Y.

    1. If X ⊇ Y then X  →    Y  

    Example:

    1. X = {a, b, c, d, e}  
    2. Y = {a, b, c}  

    2. Augmentation Rule (IR2)

    The augmentation is also called as a partial dependency. In augmentation, if X determines Y, then XZ determines YZ for any Z.

    1. If X    →  Y then XZ   →   YZ   

    Example:

    1. For R(ABCD),  if A   →   B then AC  →   BC  

    3. Transitive Rule (IR3)

    In the transitive rule, if X determines Y and Y determine Z, then X must also determine Z.

    1. If X   →   Y and Y  →  Z then X  →   Z    

    4. Union Rule (IR4)

    Union rule says, if X determines Y and X determines Z, then X must also determine Y and Z.

    1. If X    →  Y and X   →  Z then X  →    YZ     

    Proof:

    1. X → Y (given)
    2. X → Z (given)
    3. X → XY (using IR2 on 1 by augmentation with X. Where XX = X)
    4. XY → YZ (using IR2 on 2 by augmentation with Y)
    5. X → YZ (using IR3 on 3 and 4)

    5. Decomposition Rule (IR5)

    Decomposition rule is also known as project rule. It is the reverse of union rule.

    This Rule says, if X determines Y and Z, then X determines Y and X determines Z separately.

    1. If X   →   YZ then X   →   Y and X  →    Z   

    Proof:

    1. X → YZ (given)
    2. YZ → Y (using IR1 Rule)
    3. X → Y (using IR3 on 1 and 2)

    6. Pseudo transitive Rule (IR6)

    In Pseudo transitive Rule, if X determines Y and YZ determines W, then XZ determines W.

    1. If X   →   Y and YZ   →   W then XZ   →   W   

    Proof:

    1. X → Y (given)
    2. WY → Z (given)
    3. WX → WY (using IR2 on 1 by augmenting with W)
    4. WX → Z (using IR3 on 3 and 2)

    Read More
    • Share This:  
    •  Facebook
    •  Twitter
    •  Google+
    •  Stumble
    •  Digg

    Functional Dependency

     Programing Coderfunda     April 08, 2022     DBMS     No comments   

     

    Functional Dependency

    Functional dependency is a relationship that exists between two attributes. It typically exists between the primary key and non-key attribute within a table.

    1. X   →   Y  

    The left side of FD is known as a determinant, and the right side of the production is known as a dependent.

    For example:

    Assume we have an employee table with Emp_Id, Emp_Name, Emp_Addressand  attributes.

    Here Emp_Id attribute can uniquely identify the Emp_Name attribute of the employee table because if we know the Emp_Id, we can tell that the employee name is associated with it.

    Functional dependency can be written as:

    1. Emp_Id → Emp_Name   

    We can say that Emp_Name is functionally dependent on Emp_Id.

    Types of Functional dependency


    DBMS Functional Dependency

    1. Trivial functional dependency

    • A → B has trivial functional dependency if B is a subset of A.
    • The following dependencies are also trivial: A → A, B → B

    Example:

    1. Consider a table with two columns Employee_Id and Employee_Name.  
    2. {Employee_id, Employee_Name}   →    Employee_Id is a trivial functional dependency as   
    3. Employee_Id is a subset of {Employee_Id, Employee_Name}.  
    4. Also, Employee_Id → Employee_Id and Employee_Name   →    Employee_Name are trivial dependencies too.  

    2. Non-trivial functional dependency

    • A → B has a non-trivial functional dependency if B is not a subset of A.
    • When A intersection B is NULL, then A → B is called a complete non-trivial.

    Example:

    1. ID   →    Name,  
    2. Name   →    DOB  

    Read More
    • Share This:  
    •  Facebook
    •  Twitter
    •  Google+
    •  Stumble
    •  Digg
    Newer Posts Older Posts Home

    Meta

    Popular Posts

    • Vue.js Tutorial
        Vue.js Installation Compatibility Check Before going to install and use Vue.js in your project, you should check the compatibility issues....
    • JqueryUI Tutorial
      JqueryUI Tutorial    JqueryUI is the most popular front end frameworks currently. It is sleek, intuitive, and powerful mobile first fr...
    • Laravel - Application Structure
      The application structure in Laravel is basically the structure of folders, sub-folders and files included in a project. Once we create a ...
    • Python Tutorial
        Python   is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van...
    • CSS Online Training
      CSS Online Training CSS is used to control the style of a web document in a simple and easy way. CSS is the acronym for "Casca...

    Categories

    • Ajax (26)
    • Bootstrap (30)
    • DBMS (42)
    • HTML (12)
    • HTML5 (45)
    • JavaScript (10)
    • Jquery (34)
    • Jquery UI (2)
    • JqueryUI (32)
    • Laravel (1017)
    • Laravel Tutorials (23)
    • Laravel-Question (6)
    • Magento (9)
    • Magento 2 (95)
    • MariaDB (1)
    • MySql Tutorial (2)
    • PHP-Interview-Questions (3)
    • Php Question (13)
    • Python (36)
    • RDBMS (13)
    • SQL Tutorial (79)
    • Vue.js Tutorial (69)
    • Wordpress (150)
    • Wordpress Theme (3)
    • codeigniter (108)
    • oops (4)
    • php (853)

    Social Media Links

    • Follow on Twitter
    • Like on Facebook
    • Subscribe on Youtube
    • Follow on Instagram

    Pages

    • Home
    • Contact Us
    • Privacy Policy
    • About us

    Blog Archive

    • July (4)
    • September (100)
    • August (50)
    • July (56)
    • June (46)
    • May (59)
    • April (50)
    • March (60)
    • February (42)
    • January (53)
    • December (58)
    • November (61)
    • October (39)
    • September (36)
    • August (36)
    • July (34)
    • June (34)
    • May (36)
    • April (29)
    • March (82)
    • February (1)
    • January (8)
    • December (14)
    • November (41)
    • October (13)
    • September (5)
    • August (48)
    • July (9)
    • June (6)
    • May (119)
    • April (259)
    • March (122)
    • February (368)
    • January (33)
    • October (2)
    • July (11)
    • June (29)
    • May (25)
    • April (168)
    • March (93)
    • February (60)
    • January (28)
    • December (195)
    • November (24)
    • October (40)
    • September (55)
    • August (6)
    • July (48)
    • May (2)
    • January (2)
    • July (6)
    • June (6)
    • February (17)
    • January (69)
    • December (122)
    • November (56)
    • October (92)
    • September (76)
    • August (6)

    Loading...

    Laravel News

    Loading...

    Copyright © CoderFunda | Powered by Blogger
    Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda