Intro into Database Management
Published: 2021-01-19 09:16:58

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">I will be mostly focusing on SQL databases, along with how to implement a database in AWS cloud.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">The information in this blog contains,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Page 1: What do you mean by database, database languages. </li><li>Page 2: Entity Relation Diagram, Relational schema and converting ER into Relational.</li><li>Page 3: Relational Algebra and Calculus&nbsp;:</li><li>Page 4: Data base design, anomalies present, normalization forms and an example. </li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":5} -->
<h5>Q. <strong>What is data  and <strong>a database</strong>? </strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Data is raw information. For example, your daily usage of mobile. It is raw information about the time you spent on you phone, but if you analyze it,  how much time did you spend on an app per day, then it becomes information.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong>A database is a collection of related data which can be used:&nbsp;​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":413,"height":279,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.w3resource.com%2Fw3r_images%2Fsql-works-with-rdbms.gif&amp;f=1&amp;nofb=1" alt="" width="413" height="279"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong>Q. What is Database Management?</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A DBMS is a collection of programs which​,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Provide management of databases</li><li>Control access to data present in databases</li><li>Contain a query language to retrieve information easily from a database</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p> An example of database, where data is collected, maintained, and used would be the WordPress site database.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Two main uses of database are,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Storing information</li><li>Sorting information</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2753,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-2.jpg?w=529" alt="" class="wp-image-2753"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong><em>Database System = Database + Database Management System​</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4><strong>Schema of a database:</strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Schema describes the logical structure of the database, the overall of the database is also called the database schema.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A schema diagram, as shown below, displays only names of record types (entities) and names of data items (attributes) and does not show the relationships among the various files.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2755,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-3.jpg?w=560" alt="" class="wp-image-2755"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The schema will remain the same while the values filled into it change from instant to instant. When the schema framework is filled in with data item values, it is referred as an instance of the schema. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The data in the database at a particular moment of time is called a database state or snapshot, which is also called the current set of occurrences or instances in the database&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="http://programmerprodigycode.files.wordpress.com/2020/12/201fb-iu.gif" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Database Languages:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>1.Data Definition Language(DDL):</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Mainly concerned with definition of data . It is a language that allows the users to define data and their relationship to other types of data. &nbsp;​</li><li>It is also used to specify the structure of each table, set of associated values with each attribute, integrity constraints, security and authorization information for each table. The following table gives an overview about usage of DDL statements in SQL​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2766,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-5.jpg?w=591" alt="" class="wp-image-2766"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>2.<strong>Data Manipulation Language(DML)</strong>​:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Enables user to access or manipulate data&nbsp;&nbsp;​</li><li>Insertion of new information into the database​</li><li>Deletion of information from the database​</li><li>Modification of information stored in the database​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2768,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-6.jpg?w=575" alt="" class="wp-image-2768"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>3.<strong>Data Control Language(DCL)</strong>​:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>DCL statements control access to data and the database using statements such as GRANT and REVOKE. &nbsp;​ </li><li>The privileges assigned can be SELECT, ALTER, DELETE, EXECUTE, INSERT, INDEX etc. In addition to granting of privileges, you can also revoke (taken back) it by using REVOKE command.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"width":642,"height":422,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large is-resized"><img src="http://programmerprodigycode.files.wordpress.com/2020/12/f17b1-iu.jpg" alt="" width="642" height="422"/></figure>
<!-- /wp:image -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading -->
<h2><strong>Data Models: </strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>It is a collection of tools for describing&nbsp;​ data,​ data relationships​, data semantics​ and data constraints​.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>1.Entity- Relationship model:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>An entity-relationship diagram (ERD) is a data modeling technique that graphically illustrates an information system’s entities and the relationships between those entities. An ERD is a conceptual and representational model of data used to represent the entity framework infrastructure. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>In simple terms , E-R model is a <em>conceptual level</em> model. Entity-Relationship model is based on the notion of real world entities and relationship among them.&nbsp;​</strong> ER Model is based on:​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Entities and their <em>attributes</em>​ </li><li>Relationships among entities​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":542,"height":371,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fermodeldiagram.com%2Fwp-content%2Fuploads%2F2019%2F12%2Fer-diagram-tutorial-in-dbms-with-example-pertaining-to-weak-entity-in-dbms-with-example.png&amp;f=1&amp;nofb=1" alt="" width="542" height="371"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>1. <strong>Entity</strong>: An entity can be a person, place, object, event or concept in the user environment about which the organization wishes to maintain data.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Real-world object distinguishable from other objects.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>2.<strong>Entity sets</strong>: A collection of similar entities.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>All entities in an entity set have the same set of attributes​</li><li>Each entity set has a <em>key</em>​</li><li>Each attribute has a <em>domain</em>​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>3.Weak entity</strong>: A weak entity is an entity that depends on the existence of another entity. In more technical terms it can defined as an entity that cannot be identified by its own attributes. It uses a foreign key combined with its attributed to form the primary key.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The order item will be meaningless without an order so it depends on the existence of order.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2792,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-8.jpg?w=300" alt="" class="wp-image-2792"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong>Difference between strong and weak entity.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"width":573,"height":558,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fpediaa.com%2Fwp-content%2Fuploads%2F2019%2F04%2FDifference-Between-Weak-Entity-and-Strong-Entity-Comparison-Summary-e1556007799383.jpg&amp;f=1&amp;nofb=1" alt="" width="573" height="558"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4>4.Attributes: </h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A named property or characteristic of an entity that is of interest to an organization, ​Different Attribute Types​,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Composite Vs. Simple Attributes: an example for composite would be Name= First name + last name. Where as in simple one, name would be equal to first name.</li><li>Single-valued Vs. Multi-valued Attributes​: an example for this would be an email id, if it is single valued then it can only store one email id per key, where as in multi valued it could store N number of email id per key,</li><li>Derived attributes:&nbsp;​ an example for this would be storing date of birth, and calculating age from it.</li><li>Key attributes :Covered below.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.gatevidyalay.com%2Fwp-content%2Fuploads%2F2018%2F05%2FAttributes-in-ER-Diagram-1.png&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4>5.Relationships:</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A relationship describes how entities interact.&nbsp;​ Degree of a relationship is the number of entity types that participate in it​, Types of degree's of a relationship,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Unary Relationship​: One entity related to another of the same entity type​</li><li>Binary Relationship​: Entities of two different types related to each other​</li><li>Ternary Relationship​: Entities of three different types related to each other​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":560,"height":404,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.geocities.ws%2Finf381%2Fchap10%2Ffig10-6.jpg&amp;f=1&amp;nofb=1" alt="" width="560" height="404"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>1.<strong>Cardinalities of Relationships</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I try to use a verb to connect two entities. For example, </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A student can attend many classes, one class can be attended by many students.</li><li>A driver  can own many cars, but a car cannot be owned by many drivers.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Types of relationships,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>One to One relationship: one element in set A to one element in set B</li><li>One to Many relationship: one element in set A to many elements in set B </li><li>Many to One relationship: many elements in set A to one element in set B </li><li>Many to many relationship: many elements in set A to many elements in set B</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","width":412,"height":324,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2FIGdVR.png&amp;f=1&amp;nofb=1" alt="" width="412" height="324"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>2.<strong>Cardinality constraints</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I try to use a use case to form a constraint between two entities. For example,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A student must attend at least one class, one class can be attended by many students.</li><li>A driver can own at a least car, but a car cannot be owned by many drivers.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Types of cardinality constraints,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Mandatory one: At least one element</li><li>Mandatory many: At least more than one</li><li>Optional one: one or zero </li><li>Optional many:  zero or more than one</li></ol>
<!-- /wp:list -->

<!-- wp:image {"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fsites.google.com%2Fsite%2Fmerasemester%2F_%2Frsrc%2F1304431128759%2Fdbm%2Fchapter-3%2FERD.bmp&amp;f=1&amp;nofb=1" alt=""/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong>6.Identifier (Key)</strong>​:</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A key is an attribute or a combination of attributes that is used to identify records.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Sometimes we might have to retrieve data from more than one table, in those cases we require to join tables with the help of keys.​ <strong>The purpose of the key is to bind data together across tables without repeating all of the data in every table</strong>.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>1.<strong>Super Key</strong>: An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. A table can have many Super Keys.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>2.<strong>Candidate key</strong>: An attribute or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the records uniquely.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In order to be eligible for a candidate key it must pass certain criteria:​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>It must contain unique values​</li><li>It must not contain null values​</li><li>It contains the minimum number of fields to ensure uniqueness​ </li><li>It must uniquely identify each record in the table​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>3.<strong>Primary key:</strong> A Candidate Key that is used by the database designer for unique identification of each row in a table is known as Primary Key. A Primary Key can consist of one or more attributes of a table.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&nbsp;As with any candidate key the primary key must contain unique values, must never be null and uniquely identify each record in the table.&nbsp;&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>4. <strong>Foreign Key</strong>: A foreign key is an attribute or combination of attribute in one base table that points to the candidate key (generally it is the primary key) of another table.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&nbsp;The purpose of the foreign key is to ensure referential integrity of the data i.e. only values that are supposed to appear in the database are permitted​.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>5.<strong>Composite Key: </strong>If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key (also called a Compound Key or Concatenated Key).&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>6.<strong>Alternate Key</strong>: Alternate Key can be any of the Candidate Keys except for the Primary Key.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>7.Secondary Key: </strong>The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2800,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-9.jpg?w=639" alt="" class="wp-image-2800"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong>7.Integrity Constraints</strong>​</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Integrity constraints are a set of rules. It is used to maintain the quality of information.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Integrity constraints ensure that the data insertion, updating, and other processes have to be performed in such a way that data integrity is not affected.​ Thus, integrity constraint is used to guard against accidental damage to the database.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>​1.Entity Constraint​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>The entity integrity constraint states that primary key value can't be null.​</li><li>This is because the primary key value is used to identify individual rows in relation and if the primary key has a null value, then we can't identify those rows.​&nbsp;​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2827,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-23.jpg?w=509" alt="" class="wp-image-2827"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>2.Domain Constraint​</strong>:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Domain constraints can be defined as the definition of a valid set of values for an attribute.​</li><li>The data type of domain includes string, character, integer, time, date, currency, etc. The value of the attribute must be available in the corresponding domain.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2829,"width":416,"height":212,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-24.jpg?w=416" alt="" class="wp-image-2829" width="416" height="212"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>3.Check Constraint​:</strong> A check constraint allows to state a minimum requirement for the value in a column.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2830,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-25.jpg?w=478" alt="" class="wp-image-2830"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>4.Unique Constraint</strong>​: The UNIQUE constraint ensures that all values in a column are different. Both the UNIQUE and <strong>PRIMARY KEY</strong> constraints provide a guarantee for uniqueness for a column or set of columns.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2832,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-26.jpg?w=354" alt="" class="wp-image-2832"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>5.Referential Integrity</strong>​:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A referential integrity constraint is specified between two tables.</li><li>In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2833,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-27.jpg?w=403" alt="" class="wp-image-2833"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong>8.Key Constraints</strong>​</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>1.<strong>Primary Key Constraint</strong>​: Primary key is to uniquely identify each record in a table. It must have unique values and cannot contain nulls. Thus PRIMARY KEY = NOT NULL+ UNIQUE.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Foreign Key Constraint</strong>​: Foreign keys are the fields of a table that point to the primary key of another table. They act as a cross-reference between tables.&nbsp;​It has two types:​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Cascade Update​</li><li>Cascade Delete​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2835,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-28.jpg?w=413" alt="" class="wp-image-2835"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>3.<strong>Default Constraint</strong>: ​The <strong>DEFAULT constraint</strong> is used to provide a <strong>default</strong> value for a column. The <strong>default</strong> value will be added to all new records IF no other value is specified.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2836,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-29.jpg?w=525" alt="" class="wp-image-2836"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>2.Relational Model:</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In this model ,data is organized in two dimensional tables called relations.&nbsp;​ Relational Model is made up of tables​,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>A row of table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = a relational instance/tuple​</li><li>A column of table&nbsp;&nbsp; = an attribute​</li><li>A table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = a schema/relation​</li><li>Cardinality&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = number of rows​</li><li>Degree&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = number of columns​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.w3schools.in%2Fwp-content%2Fuploads%2F2016%2F08%2FRelational-Model-Terms.png&amp;f=1&amp;nofb=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>3.<strong>Conversion Rules​ to relational model</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>STEP 1: </strong>For each non-weak entity, create a relation (or table) that includes all of the simple attributes of that entity.​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Do not include multi valued attributes or derived attributes at this time. If you have a composite attribute, include only the component attributes.​</li><li>Choose one of the candidate keys to be the primary key of the table.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2802,"width":414,"height":253,"sizeSlug":"large","linkDestination":"none","className":"is-style-default"} -->
<div class="wp-block-image is-style-default"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-10.jpg?w=561" alt="" class="wp-image-2802" width="414" height="253"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>STEP 2:&nbsp;</strong>​For each weak entity, create a relation that includes all simple attributes&nbsp; of the weak entity.​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>In addition, include as a foreign key attribute the primary key of the owning entity.​</li><li>The primary key of this relation will be the combination of the primary key of the owning entity and the partial key of the weak entity.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"left","id":2804,"width":326,"height":197,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="alignleft size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-11.jpg?w=658" alt="" class="wp-image-2804" width="326" height="197"/></figure></div>
<!-- /wp:image -->

<!-- wp:image {"align":"center","id":2806,"width":-359,"height":-264,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-12.jpg?w=586" alt="" class="wp-image-2806" width="-359" height="-264"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Step 3:</strong> For each multi valued attribute, create a new relation that includes that attribute, plus the primary key of the entity to whom that attribute belongs as a foreign key. The primary key of this new relation will be the combination of the foreign key and the attribute itself.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2808,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-13.jpg?w=587" alt="" class="wp-image-2808"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Step 4:</strong> Convert relationships into relational model,</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Relationship Conversion: 1:1​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For each binary 1:1 relationship, identify the two entities that participate in that relationship. Take the primary key from table and include it as a foreign key in the other table​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"left","id":2810,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="alignleft size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-14.jpg?w=311" alt="" class="wp-image-2810"/></figure></div>
<!-- /wp:image -->

<!-- wp:image {"id":2811,"width":404,"height":163,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-15.jpg?w=565" alt="" class="wp-image-2811" width="404" height="163"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>2.Relationship Conversion: 1:N​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For each 1:N relationship, the primary key of “1” side is added as a foreign key in the table on “N” side entity.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2813,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-16.jpg?w=295" alt="" class="wp-image-2813"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":2814,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-17.jpg?w=620" alt="" class="wp-image-2814"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>3.Relationship Conversion: M:N​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For each binary M:N relationship, create a new relation to represent the relationship. Include in this relation as foreign keys the primary keys of each of the entities that participates in the relationship. The combination of these foreign keys will make up the primary key for the new table.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2815,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-18.jpg?w=591" alt="" class="wp-image-2815"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>4.Conversion of N-ary relationship​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For each n-ary relationship create a relation to represent it. Add a foreign key into each participating entity type. Also add any attributes of the relationship. The primary key of this relation is the combination of all foreign keys into participating entity&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2816,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-19.jpg?w=594" alt="" class="wp-image-2816"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Step 5: </strong>Checking for sub classes and super classes  </p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Super-class</strong>: An entity type that includes one or more dissimilar sub-groupings of its occurrences that is required to be represented in a data model.</li><li><strong>Sub-class</strong>: A distinct sub-grouping of occurrences of an entity type that require being represented in a data model.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>1. Generalization:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Generalization is the process of extracting common properties from a set of entities and creating a generalized entity from it. <strong>It is a bottom-up approach in which two or more entities can be generalized to a higher level entity if they have some attributes in common</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2856,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-31.jpg?w=425" alt="" class="wp-image-2856"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>2.Specialization:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In specialization, an entity is divided into sub-entities based on their characteristics.<strong> It is a top-down approach where a higher level entity is specialized into two or more lower level entities.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2820,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-21.jpg?w=403" alt="" class="wp-image-2820"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>3.Aggregation:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Sometimes you may want to model a 'has-a,' 'is-a' or 'is-part-of' relationship, in which one entity represents a larger entity (the 'whole') that will consist of smaller entities (the 'parts'). This special kind of relationship is termed as an aggregation. Aggregation does not change the meaning of navigation and routing across the relationship between the whole and its parts.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2821,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-22.jpg?w=472" alt="" class="wp-image-2821"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4>Q. How to confirm a database is Relational?</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Codd's rules proposed by E. F. Codd, designed to define what is required from a database management system in order for it to be considered <em>relational</em> <strong>.​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For a system to qualify as a relational database management system (RDBMS), that system must use its <em>relational</em> facilities to <em>manage</em> the database.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For more information on codd's twelve rules, <a rel="noreferrer noopener" href="https://www.red-gate.com/simple-talk/homepage/codds-twelve-rules/" target="_blank">refer this article by Joe Celko</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"level":3} -->
<h3><strong>Relational Algebra and Calculus&nbsp;</strong>:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Query Languages are structured commands to insert and retrieve data from a database.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","width":351,"height":246,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fbeginnersbook.com%2Fwp-content%2Fuploads%2F2019%2F02%2FRelational_algebra__calculus.png&amp;f=1&amp;nofb=1" alt="" width="351" height="246"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Relational&nbsp; Query Languages</strong>​</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>The <em>Relational Algebra</em> is an algebraic notation, where queries are expressed by applying specialized operators to the relations.​</li></ul>
<!-- /wp:list -->

<!-- wp:list -->
<ul><li>The <em>Relational Calculus</em> which is a logical notation, where queries are expressed by formulating some logical restrictions that the tuples in the answer must satisfy.&nbsp;​</li></ul>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2865,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-32.jpg?w=465" alt="" class="wp-image-2865"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3><strong>Relational Algebra</strong>​:</h3>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>Relational algebra operations work on one or more relations to define another relation without changing the original relations.&nbsp;​ </li><li>Both operands and results are relations, so output from one operation can become input to another operation.&nbsp;​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>There are six basic operations in relational algebra,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Selection,&nbsp;​</li><li>Projection,&nbsp;​</li><li>Intersection&nbsp;​</li><li>Cartesian product​</li><li>Union​</li><li>Set Difference.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2869,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-34.jpg?w=570" alt="" class="wp-image-2869"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>1.Selection:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Works on a single relation R and defines a relation that contains only those tuples (rows) of R that satisfy the specified condition (predicate).&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:preformatted -->
<pre class="wp-block-preformatted"><strong>In general&nbsp; the select operation is denoted as</strong>​ <strong>σ &lt;selection condition&gt;(R)</strong>​</pre>
<!-- /wp:preformatted -->

<!-- wp:paragraph -->
<p>For example, List all staff with a salary greater than £10,000.​ </p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>σsalary &gt; 10000(Staff) ​</code></pre>
<!-- /wp:code -->

<!-- wp:image {"align":"center","id":2932,"width":322,"height":220,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-63.jpg?w=586" alt="" class="wp-image-2932" width="322" height="220"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>2.Projection:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Works on a single relation R and defines a relation that contains a vertical subset of R,​ extracting the values of specified attributes and​<br>eliminating duplicates.​</p>
<!-- /wp:paragraph -->

<!-- wp:preformatted -->
<pre class="wp-block-preformatted"><strong>The general form of the PROJECTION operation is</strong>​ <strong>Π&lt;attribute list&gt;(R)</strong>​</pre>
<!-- /wp:preformatted -->

<!-- wp:paragraph -->
<p>For example,  Produce a list of salaries for all staff, showing only staffNo, fName, lName, and salary details.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">ΠstaffNo, fName, lName, salary (Staff) ​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:image {"align":"center","id":2933,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-5.png?w=552" alt="" class="wp-image-2933"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong><em>We can use Selection as well as projection in one query statement,</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2890,"width":494,"height":410,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-47.jpg?w=514" alt="" class="wp-image-2890" width="494" height="410"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>3.Set Operations:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>It takes an input of two relations instances, they require to input set to be compatible.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>They have the same number of fields</li><li>Corresponding fields, taken in order from left to right have the same domains.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong><em>1.Union:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Union of two relations R and S defines a relation that contains all the tuples of R, or S, or both R and S, duplicate tuples being eliminated.&nbsp;​</li><li>​R and S must be union-compatible.&nbsp;​ </li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2894,"width":330,"height":249,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-48.jpg?w=518" alt="" class="wp-image-2894" width="330" height="249"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>2.Intersection:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Defines a relation consisting of the set of all tuples that are in both R and S.&nbsp;​ </li><li>R and S must be union-compatible.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2895,"width":361,"height":213,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-49.jpg?w=609" alt="" class="wp-image-2895" width="361" height="213"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>3.Set difference :</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Defines a relation consisting of the tuples that are in relation R, but not in S.   </li><li>R and S must be union-compatible.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2897,"width":381,"height":251,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-50.jpg?w=581" alt="" class="wp-image-2897" width="381" height="251"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>4.Cartesian product​:</em></strong> Defines a relation that is the concatenation of every tuple of relation R with every tuple of relation S.&nbsp;​ ​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2898,"width":397,"height":247,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-51.jpg?w=534" alt="" class="wp-image-2898" width="397" height="247"/></figure></div>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>4.Division:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Division is typically required when you want to find out entities that are interacting with&nbsp;all<strong> </strong>entities&nbsp;of a set of different type entities.​<br>The division operator is used when we have to evaluate queries which contain the keyword ‘all’.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Division is not supported by SQL implementations. However, it can be represented using other operations.(like cross join, Except, In )​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Given two relations(tables): R(x,y) , S(y).</strong>​<br><strong>R and S</strong>&nbsp;: tables​<br><strong>x and y</strong>&nbsp;: column of R​<br><strong>y</strong>&nbsp;: column of S​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>R(x,y) div S(y)&nbsp;means gives all distinct values of x from R that are associated with all values of y in S.​</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2901,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-52.jpg?w=642" alt="" class="wp-image-2901"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4><strong><em>5.Join​:</em></strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The join operation is used to combine related tuples from two relations into single tuples.​ ​​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">The general form of a join operation on two relations R(A1,A2,…An) and S(B1,B2,…Bm ) is R⋈&lt;join condition>S​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:paragraph -->
<p><strong>Some important points about joints:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>You can nest and chain joins to join more than two tables, but DBMS works its way through your query by executing joins on exactly two tables at a time.</li><li>If a join's connecting columns contains nulls, the nulls never join.</li><li>Joins exist only for the duration a query and aren't part of the database.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2905,"width":491,"height":344,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-4.png?w=649" alt="" class="wp-image-2905" width="491" height="344"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>1.Cross Joins: </strong>Cross join is also referred to as Cartesian Product. For every row in the LEFT Table of the CROSS JOIN all the rows from the RIGHT table are returned and Vice-Versa.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2907,"width":397,"height":304,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-53.jpg?w=570" alt="" class="wp-image-2907" width="397" height="304"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>2.Equi Joins:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>SQL EQUI JOIN performs a JOIN against equality or matching column(s) values of the associated tables. An equal sign (=) is used as comparison operator in the where clause to refer equality.​</li><li>You may also perform EQUI JOIN by using JOIN keyword followed by ON keyword and then specifying names of the columns along with their associated tables to check equality.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":2909,"width":309,"height":401,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-54.jpg?w=372" alt="" class="wp-image-2909" width="309" height="401"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong><em>3.Natural Joins:</em></strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>It is a special case of an equijoin, it compares all the columns in one table with corresponding columns that have the same name in the other table for equality.</li><li>Works only if the input tables have one or more pairs of meaningfully comparable, identically named columns</li><li>Performs join implicitly, It can  be replicated explicitly with an ON clause in JOIN syntax or a WHERE  clause in WHERE syntax.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2911,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-55.jpg?w=598" alt="" class="wp-image-2911"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>4.Inner Joins:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>It combines the rows retrieved from multiple tables on the basis of the common columns of the table or any conditions that tuples satisfy.​  ​</li><li>In this kind of a JOIN, we get all records that match the condition in both the tables, and records in both the tables that do not match are not reported. ​</li><li>INNER JOIN is based on the single fact that : ONLY the matching entries in BOTH the tables SHOULD be listed.​​ </li></ol>
<!-- /wp:list -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">SELECT * FROM​ A INNER JOIN B​ USING (col1, col2,…)</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:image {"align":"center","id":2916,"width":544,"height":354,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-57.jpg?w=632" alt="" class="wp-image-2916" width="544" height="354"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>5.Left joins:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Left Outer Join/Left Join returns all the rows from the LEFT table and the corresponding matching rows from the right table. If right table doesn’t have the matching record then for such records right table column will have NULL value in the result.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2917,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-58.jpg?w=547" alt="" class="wp-image-2917"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>6.Right Outer Join:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Right Outer Join/Right Join returns all the rows from the RIGHT table and the corresponding matching rows from the left table. If left table doesn’t have the matching record then for such records left table column will have NULL value in the result.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2919,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-59.jpg?w=597" alt="" class="wp-image-2919"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>7.FULL OUTER JOIN​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It returns all the rows from both the tables, if there is no matching row in either of the sides&nbsp;then it displays NULL values in the result for that table columns in such rows.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Full Outer Join = Left Outer Join + Right Outer Join</strong>​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2920,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-60.jpg?w=607" alt="" class="wp-image-2920"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>​8.Self Joins:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If a Table is joined to itself using one of the join types explained above, then such a type of join is called SELF JOIN.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2923,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-62.jpg?w=514" alt="" class="wp-image-2923"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now if we need to get the name of the Employee and his Manager name for each employee in the Employee Table. Then we have to Join Employee Table to itself as Employee and his Manager data is present in this table only as shown in the below query:​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2922,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-61.jpg?w=624" alt="" class="wp-image-2922"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3><strong>Relational Calculus</strong>​:</h3>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>Relational calculus query specifies what is to be retrieved rather than how to retrieve it.&nbsp;​ ​</li><li>No description of how to evaluate a query.&nbsp;​ ​</li><li>Non procedural language.​ ​</li><li>When applied to databases, relational calculus has forms : tuple and&nbsp; domain.&nbsp;​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"align":"center","sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse4.mm.bing.net%2Fth%3Fid%3DOIP.CaizWCpz8odiQD5sykLfRwAAAA%26pid%3DApi&amp;f=1" alt=""/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>1.Tuple relational Calculus:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Tuple variable is a variable that ‘ranges over’ a named relation: i.e., variable whose only permitted values are tuples of the relation.​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">A simple tuple relational calculus query is of the form {t | COND(t)}​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:paragraph -->
<p>where t is a tuple variable and COND(t) is a conditional expression involving . ​The result is set of all tuples t that satisfy COND(t)​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For example, To find details of all staff earning more than £10,000:&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">    {S | Staff(S) AND S.salary > 10000} ​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:paragraph -->
<p><strong>2.Domain Relational Calculus:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Uses variables that take values from domains instead of tuples of relations.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If F(d1,d2, . . . ,dn) stands for a formula composed of atoms and d1,d2, . . . ,dn represent domain variables, then:​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code"> {d1,d2, . . . ,dn | F(d1,d2, . . . ,dn)} is a general domain relational calculus expression. ​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:paragraph -->
<p>For example, Find the names of all managers who earn more than £25,000.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:syntaxhighlighter/code -->
<pre class="wp-block-syntaxhighlighter-code">fN, lN | ( sN, posn, sex, DOB, sal, bN)​ (Staff (sN, fN, lN, posn, sex, DOB, sal, bN) AND posn = ‘Manager’AND  sal > 25000)}​</pre>
<!-- /wp:syntaxhighlighter/code -->

<!-- wp:nextpage -->
<!--nextpage-->
<!-- /wp:nextpage -->

<!-- wp:heading {"level":3} -->
<h3>Database Development Life cycle​</h3>
<!-- /wp:heading -->

<!-- wp:image {"align":"center","id":2944,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-6.png?w=500" alt="" class="wp-image-2944"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>1.Requirement Analysis:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Requirements analysis is done in order to understand the problem, which is to be solved.&nbsp;​ There are two major activities in requirements analysis,</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Problem understanding or analysis&nbsp;​</li><li>Requirement specifications.&nbsp;</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Goals of Requirements Analysis​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>To determine the data requirements of the database in terms of primitive objects.​ </li><li>To classify and describe the information about these objects .​ .</li><li>to identify and classify the relationships among the objects.&nbsp;​​</li><li>To determine the types of transactions that will be executed on the database and the interactions between the data and the transactions​.</li><li>To identify rules governing the integrity of the data&nbsp;.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>2.<strong>Database Design:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>In this phase, the information models that were developed during analysis are used to design a conceptual schema for the database and to design transaction and application.&nbsp;​​</li><li>In conceptual schema design, the data requirements collected in Requirement Analysis phase are examined and a conceptual database schema is produced.&nbsp; ​​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>3.Database Design Framework​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Determine the information requirements.​​</li><li>Analyse the real-world objects that you want to model in the database.​ ​</li><li>Determine primary key attributes. ​</li><li>Develop a set of rules that govern how each table is accessed, populated and updated.​ ​</li><li>Identify relationship between the entities.​ ​</li><li>Plan database security.​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>4.DBMS Selection​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In this phase an appropriate DBMS is selected to support the information system.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A number of factors are involved in DBMS selection. They may be technical and economical factors.​ The technical factors are concerned with the suitability of the DBMS for information system.&nbsp;​ The following technical factors are considered.​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Type of DBMS such as relational, object-oriented etc ​</li><li>Storage structure and access methods that the DBMS supports.&nbsp;​</li><li>User and programmer interfaces available.&nbsp;​</li><li>Type of query languages.&nbsp;​</li><li>Development tools etc.&nbsp;&nbsp;​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>5.Implementation&nbsp;:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>After the design phase and selecting a suitable DBMS, the database system is implemented.&nbsp;​</li><li>The purpose of this phase is to construct and install the information system according to the plan and design as described in previous phases.&nbsp;​</li><li>Implementation involves a series of steps leading to operational information system that includes creating database definitions, developing applications, testing the system, developing operational procedures and documentation, training the users and populating the database.&nbsp;​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>6.Design guidelines for Relational Schema​:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Meaning of the relation (Table) attributes, It should be easy to explain the meaning of entities and relationship between entities.</li><li>Reducing repetitive values in the tuples, try to follow DRY concept </li><li>Reducing the null values in the tuples: try to avoid, placing the attributes in a base relation whose value may usually be null. </li><li>Not allowing the possibility of bogus tuples, When the tables are joined with equality conditions on attributes that are either primary key or foreign key.</li></ol>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4>7.Functional dependencies:</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A functional dependency is an association between two attributes of the same relational database table. One of the attributes is called the determinant and the other attribute is called the determined. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If A is the determinant and B is the determined then we say that A functionally determines B and graphically represent this as A -&gt; B.&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2946,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-7.png?w=561" alt="" class="wp-image-2946"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong>Types of Functional Dependency​:</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>1.Partial Dependency and Fully Functional Dependency:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Partial Dependency:</strong> If you have more than one attributes in primary key. Let A be the non prime key attribute. If A is not dependent upon all prime key attributes then partial dependency exists.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Fully functional dependency:</strong> Let A be the non-prime key attribute and value of A is dependent upon all prime key attributes. Then A is said to be fully functional dependent. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2953,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-67.jpg?w=664" alt="" class="wp-image-2953"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In the above example, Proj_NAME depends on Proj__NUM whereas EMP_NAME, JOB_CLASS and CHG_HOUR is depends on EMP_NUM. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A easy way to understand it would be if attribute Y is Partially dependent on the attribute X only it if it is dependent on a subset of attribute X.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Transitive and Non Transitive Dependency:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Transitive Dependency: </strong>It is due to dependency between non-prime key attributes. Suppose in a relation R, X-&gt; Y (Y depends upon X ), Y-&gt;Z (Z depends upon Y) then X -&gt;Z (depends upon X). There fore Z is said to be transitively dependent upon X.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Non Transitive dependency: </strong>There is no dependency between non-prime key attributes</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2954,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-68.jpg?w=619" alt="" class="wp-image-2954"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In the above example, CHG_HOUR depends on JOB_CLASS.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>3. Single value and multi valued Dependency:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Single valued dependency: </strong>In any relation R, if for a particular value of X, Y has single value then it is know as single valued dependency.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Multi valued dependency(MVD):</strong> In any relation R, if or a particular value of X, Y has more than one value then it is know as multi valued dependency.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Denoted by x -&gt;-&gt; Y</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2956,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-69.jpg?w=638" alt="" class="wp-image-2956"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Anomalies:</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Database anomalies are the problems in relations that occur due to redundancy in the relations. These anomalies affect the process of inserting, deleting and modifying data in the relations. Some important data may be lost if a relation is updated that contains database anomalies.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2960,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-70.jpg?w=646" alt="" class="wp-image-2960"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Relations that have redundant data may have problems called <strong>update anomalies</strong>, which are classified as ,</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Insertion Anomaly:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to add new information in any relation but cannot enter that data because of some constraints. In Employee, you can't add new department Finance unless there is an employee in Finance department.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In addition to this information, it violates Entity integrity Rule 1. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.Deletion Anomaly:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The deletion Anomaly occurs when you try to delete any existing information from any relation and this causes deletion of any other undesirable information.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In relation Employee, if you try to delete tupe containing  Deepak this leads to the deletion of the department "Sales" completely.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>3.Update Anomaly:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The update anomaly occurs when you try to update any existing information in any relation and this causes inconsistency of data.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For Example,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2963,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-71.jpg?w=577" alt="" class="wp-image-2963"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":2964,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-72.jpg?w=553" alt="" class="wp-image-2964"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4>Decomposition: </h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To Avoid anomalies and preserve the dependencies in the database.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>1.Lossless Decompostion:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>An example of this will be rather than storing all information in a single table, store it in multiple tables.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2970,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-76.jpg?w=643" alt="" class="wp-image-2970"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>After Breaking a single big table into smaller tables,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2972,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-77.jpg?w=631" alt="" class="wp-image-2972"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>2.Dependency preserving :</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If the original table is decomposed into multiple fragments, then somehow, we suppose to get all original FDs from these fragments. Every dependency in original table must be preserved or say, every dependency must be satisfied by at least one decomposed table.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2973,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-78.jpg?w=658" alt="" class="wp-image-2973"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Database normalization:</h3>
<!-- /wp:heading -->

<!-- wp:image {"align":"center","id":2974,"width":479,"height":359,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-79.jpg?w=620" alt="" class="wp-image-2974" width="479" height="359"/></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Database designed based on ER model may have some amount of&nbsp; inconsistency, ambiguity and redundancy. To resolve these issues some amount of refinement is required. This refinement process is called as Normalization.​ It has three goals:&nbsp;​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>To eliminate redundant data (e.g. storing the same data in more than one table) a​</li><li>To store only related data in a same table.&nbsp;​</li><li>Organize data efficiently&nbsp;</li></ol>
<!-- /wp:list -->

<!-- wp:list {"ordered":true} -->
<ol><li>Both goals reduce the amount of space a database consumes, ensures data is logically stored, and maximize operational efficiency.​</li><li>A good database design includes the normalization, without normalization a database system may slow, inefficient and might not produce the expected result.​</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2977,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-80.jpg?w=609" alt="" class="wp-image-2977"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong>UNF to 1 NF:</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>First Normal Form is a relation in which the intersection of each​ row and column contains one and only one value.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There are two approaches to removing repeating groups from un-normalized tables:​</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Removes the repeating groups by entering appropriate data&nbsp;​ in the empty columns of rows containing the repeating data.​</li><li>Removes the repeating group by placing the repeating data,&nbsp;​along with a copy of the original key attribute(s), in a separate&nbsp;​ relation. A primary key is identified for the new relation.​</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>The official qualifications for 1 NF are</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Each attribute name must be unique</li><li>Each attribute values must be single</li><li>Each row must be unique</li><li>There is no repeating groups</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>For example,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2985,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-9.png?w=653" alt="" class="wp-image-2985"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>1 NF relation with the first approach</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Following the concept of atomic values</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2987,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-10.png?w=626" alt="" class="wp-image-2987"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>1 NF with the second approach</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>With the second approach, we remove the repeating group&nbsp;(property rented details) by placing the repeating data along with&nbsp;​ a copy of the original key attribute (clientNo) in a separte relation.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2988,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-11.png?w=579" alt="" class="wp-image-2988"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>1 NF to 2 NF:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Second normal form (2NF) is a relation that is in first normal form and every non-primary-key attribute is fully functionally dependent on the primary key.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After removing the partial dependencies, the creation of the three&nbsp;​ new relations called Client, Rental, and PropertyOwner​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2991,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-12.png?w=553" alt="" class="wp-image-2991"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5><strong>2 NF to 3 NF:</strong></h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A relation that is in first and second normal form, and in which&nbsp;​ no non-primary-key attribute is <strong>transitively</strong> dependent on the&nbsp;​ primary key.​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The normalization of 2NF relations to 3NF involves the removal of transitive dependencies by placing the attribute(s) in a new relation along with a copy of the determinant.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2994,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-13.png?w=554" alt="" class="wp-image-2994"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>3 NF to Boyle Codd Normal Form:</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A relation is said to be in BCNF when:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>If every determinant is a condidate key</li><li>It should be in 3 NF</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>A relation is in BCNF, if and only if, every determinant is a&nbsp;​ candidate key.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2996,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-14.png?w=480" alt="" class="wp-image-2996"/><figcaption>fd4 staffNo, interviewDate -&gt; roomNo (not a candidate key)​</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>To transform the ClientInterview relation to BCNF, we must remove the violating functional dependency by creating two new relations called Interview and SatffRoom as shown below,​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2998,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-15.png?w=560" alt="" class="wp-image-2998"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>3 NF to 4 NF </h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A relation is said to be in 4 NF when:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>It is in BCNF</li><li>There is no multivalued dependency in the relation. MVD occurs when two or more independent multi valued attributes are about the same attributes occur with same table.AS  R-&gt;-&gt;B </li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":3001,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-16.png?w=508" alt="" class="wp-image-3001"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>After applying 4 NF form,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3003,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-17.png?w=517" alt="" class="wp-image-3003"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center"><strong>A summary would be</strong></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":2999,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://programmerprodigycode.files.wordpress.com/2020/12/image-82.jpg?w=686" alt="" class="wp-image-2999"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>I worked on a Parcel Delivery System for my Junior year data base project, you can find it on GitHub.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><a href="https://github.com/kakabisht/Bluedart" target="_blank" rel="noreferrer noopener">https://github.com/kakabisht/Bluedart</a></li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>I will be trying to write more on database in cloud, for more information about it.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><a rel="noreferrer noopener" href="https://aws.amazon.com/products/databases/" target="_blank">https://aws.amazon.com/products/databases/</a></li><li><a rel="noreferrer noopener" href="https://aws.amazon.com/dynamodb/" target="_blank">Amazon DynamoDB </a>is very easy to understand and use. </li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->