{"id":22367150,"url":"https://github.com/sukhoy94/dbms-normal-forms","last_synced_at":"2026-02-21T10:31:20.722Z","repository":{"id":250473564,"uuid":"834565439","full_name":"sukhoy94/dbms-normal-forms","owner":"sukhoy94","description":"DBMS normal forms cheatsheet","archived":false,"fork":false,"pushed_at":"2024-07-28T10:07:33.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T08:46:56.382Z","etag":null,"topics":["database-design","dbms","first-normal-form","second-normal-form","third-normal-form"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sukhoy94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-27T16:51:45.000Z","updated_at":"2024-07-28T10:07:36.000Z","dependencies_parsed_at":"2025-01-31T17:13:11.872Z","dependency_job_id":"5dbc3bab-f2f4-46c2-a846-fadccbc4c84e","html_url":"https://github.com/sukhoy94/dbms-normal-forms","commit_stats":null,"previous_names":["sukhoy94/dbms-normal-forms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sukhoy94/dbms-normal-forms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fdbms-normal-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fdbms-normal-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fdbms-normal-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fdbms-normal-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sukhoy94","download_url":"https://codeload.github.com/sukhoy94/dbms-normal-forms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fdbms-normal-forms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29679049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T09:33:50.764Z","status":"ssl_error","status_checked_at":"2026-02-21T09:33:19.949Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-design","dbms","first-normal-form","second-normal-form","third-normal-form"],"created_at":"2024-12-04T18:16:35.961Z","updated_at":"2026-02-21T10:31:20.701Z","avatar_url":"https://github.com/sukhoy94.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# DBMS normal forms\n\nNormalization is a process in database design that organizes columns (attributes) and tables (relations) to minimize data redundancy. It involves dividing large tables into smaller, more manageable pieces without losing information.\n\n## 1. First Normal Form (1NF)\n\nDefinition: A table is in 1NF if:\n\n```\nAll columns contain only atomic (indivisible) values.\nEach column contains values of a single type.\nEach column contains only one value per row.\nEach row is unique.\n```\n\nExample\n\n```\n| StudentID | Name       | Courses        |\n|-----------|------------|----------------|\n| 1         | Alice      | Math, English  |\n| 2         | Bob        | Math, Science  |\n\n| StudentID | Name       | Courses        |\n|-----------|------------|----------------|\n| 1         | Alice      | Math, English  |\n| 2         | Bob        | Math, Science  |\n```\n\nTo Convert to 1NF:\n\n```\n| StudentID | Name  | Course   |\n|-----------|-------|----------|\n| 1         | Alice | Math     |\n| 1         | Alice | English  |\n| 2         | Bob   | Math     |\n| 2         | Bob   | Science  |\n```\n\n## 2. Second Normal Form (2NF)\n\nDefinition: A table is in 2NF if:\n- It is in 1NF.\n- All non-key attributes are fully functional dependent on the primary key.\n\nTo understand 2NF, we need to understand functional dependencies, particularly partial dependencies.\n\n### Functional Dependency\nA functional dependency occurs when one attribute uniquely determines another attribute. For example, if we know a student's ID, we can determine their name.\n\n### Partial Dependency\nA partial dependency occurs when a non-key attribute is functionally dependent on part of a composite key (but not the whole key). This situation arises only when the primary key is composite (consisting of two or more columns).\n\nExample:\n\nIf the primary key is a composite key, each non-key attribute must depend on the whole key, not just part of it.\n\n```\n| StudentID | CourseID | Instructor | CourseName |\n|-----------|----------|------------|------------|\n| 1         | 101      | Prof. A    | Math       |\n| 1         | 102      | Prof. B    | English    |\n| 2         | 101      | Prof. A    | Math       |\n| 2         | 103      | Prof. C    | Science    |\n\n```\n\n\n### Analysis for 2NF\n\nInstructor depends on CourseID, not on the whole composite key (StudentID, CourseID).\nCourseName depends on CourseID, not on the whole composite key (StudentID, CourseID).\nThese partial dependencies violate the 2NF rule. To convert this table into 2NF, we need to eliminate these partial dependencies.\n\n```\nStudent Course Table:\n| StudentID | CourseID |\n|-----------|----------|\n| 1         | 101      |\n| 1         | 102      |\n| 2         | 101      |\n| 2         | 103      |\n\n\nCourse Table:\n| CourseID | Instructor | CourseName |\n|----------|------------|------------|\n| 101      | Prof. A    | Math       |\n| 102      | Prof. B    | English    |\n| 103      | Prof. C    | Science    |\n\n```\n\n### Explanation\nStudent-Course Table: The StudentID and CourseID together form the composite primary key, and there are no partial dependencies because this table only contains these key attributes.\n\nCourse Table: The CourseID is now the primary key, and Instructor and CourseName are fully functionally dependent on CourseID, eliminating partial dependencies.\n\nBy decomposing the original table into these two tables, we ensure that every non-key attribute is fully functionally dependent on the entire primary key in each table. This decomposition achieves Second Normal Form (2NF), reducing redundancy and ensuring data integrity.\n\n\n## 3. Third normal form\n\nThe Third Normal Form (3NF) is a database normalization level used to reduce data redundancy and ensure data integrity. A table is in 3NF if:\n\n- It is in Second Normal Form (2NF).\n- All the attributes are functionally dependent only on the primary key and nothing else (i.e., there are no transitive dependencies).\n\nExample:\n\n\nConsider a table storing information about employees, departments, and the location of the departments:\n```\n| EmployeeID | EmployeeName | DepartmentID | DepartmentName | DepartmentLocation |\n|------------|--------------|--------------|----------------|--------------------|\n| 1          | John         | D01          | HR             | New York           |\n| 2          | Jane         | D02          | IT             | San Francisco      |\n| 3          | Bob          | D01          | HR             | New York           |\n| 4          | Alice        | D03          | Finance        | Chicago            |\n```\n\nIn this table:\n\n- The primary key is EmployeeID.\n- DepartmentName and DepartmentLocation are non-key attributes.\n\nDependencies:\n\n- EmployeeName depends on EmployeeID.\n- DepartmentName depends on DepartmentID.\n- DepartmentLocation depends on DepartmentID.\n- DepartmentID determines DepartmentName and DepartmentLocation, so there is a transitive dependency: EmployeeID -\u003e DepartmentID -\u003e DepartmentName and DepartmentLocation.\n- This table is in 2NF but not in 3NF because of the transitive dependencies.\n\nTo achieve 3NF, we need to eliminate the transitive dependencies by creating separate tables for employees and departments.\n\n```\nemployee table\n\n| EmployeeID | EmployeeName | DepartmentID |\n|------------|--------------|--------------|\n| 1          | John         | D01          |\n| 2          | Jane         | D02          |\n| 3          | Bob          | D01          |\n| 4          | Alice        | D03          |\n\ndepartment table\n\n| DepartmentID | DepartmentName | DepartmentLocation |\n|--------------|----------------|--------------------|\n| D01          | HR             | New York           |\n| D02          | IT             | San Francisco      |\n| D03          | Finance        | Chicago            |\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukhoy94%2Fdbms-normal-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsukhoy94%2Fdbms-normal-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukhoy94%2Fdbms-normal-forms/lists"}