{"id":285,"date":"2018-06-14T21:02:53","date_gmt":"2018-06-14T21:02:53","guid":{"rendered":"http:\/\/dbtut.com\/?p=285"},"modified":"2020-01-09T14:27:42","modified_gmt":"2020-01-09T14:27:42","slug":"what-is-primary-key-and-foreign-key","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/","title":{"rendered":"What is Primary Key and Foreign Key"},"content":{"rendered":"<h2>Difference Between Primary Key and Foreign Key<\/h2>\n<p>You can be find what is Primary Key and Foreign Key and what are differences between Primary Key and Foreing Key below.<\/p>\n<h2>What is Primary Key?<\/h2>\n<ul>\n<li><span style=\"font-size: 1.125rem; font-family: var(--text-font);\">Primary Keys ensures that records in the table are <strong>unique<\/strong>. <\/span>When you create a primary key on a column, a value inserted into that column can not be re-inserted. For example, you create a primary key in the ID column and you inserted a value of 1 to this column. You can not insert same value(1) to this column again. So, if you have a unique column, you can create a primary key on that column.<\/li>\n<li>A <strong>null value can not be inserted<\/strong> to Primary Key Column.<\/li>\n<li>If you create a primary key, SQL Server will create a <strong>clustered index by default<\/strong>. But you can force it to create nonclustered index. You may want to read the article named &#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2018\/06\/10\/differences-between-clustered-index-and-non-clustered-index\/\" target=\"_blank\" rel=\"noopener noreferrer\">Differences Between Clustered Index and Non Clustered Index<\/a>&#8220;<\/li>\n<li><span style=\"font-size: 1.125rem; font-family: var(--text-font);\">We <strong>can create only one<\/strong> Primary Key in a table.<\/span><\/li>\n<li><span style=\"font-size: 1.125rem; font-family: var(--text-font);\">We can create Primary Key by combining multiple columns,\u00a0 This is called the <strong>Composite Key<\/strong>.<\/span><\/li>\n<li>Primary Keys can be related with Foreigns Keys<\/li>\n<\/ul>\n<h2>What is Foreign Key?<\/h2>\n<ul>\n<li>Foreign Key is used to relate two tables to each other in relational databases.<\/li>\n<li>It can be created on a column or a combination of multiple columns. It is also referred to as a reference key.<\/li>\n<li>Foreign Keys have not to be unique.<\/li>\n<li>We can create more than one foreing key in the table.<\/li>\n<li>Sql Foreign Key values \u200b\u200bare related with Primary Key, which is located in a different table.<\/li>\n<li>If you create a Foreign Key, SQL Server will not create an index by default. But in terms of performance, you usually need to create an index on a foreign key column.<\/li>\n<li>In SQL databases, the primary key in one table and the foreign key in the other table are used to establish the relationship between the two tables.<\/li>\n<li>Unlike Primary Key, Foreing Key can be null.<\/li>\n<\/ul>\n<h2>Primary Key and Foreign Key Relationship<\/h2>\n<p><span style=\"font-size: 1.125rem; font-family: var(--text-font);\">Another feature of Primary Keys is that it can be related with Foreing Keys. <\/span><\/p>\n<p>For example, you create a primary key in the column named ID in the City Table. The other column name is CityName. Let&#8217;s imagine that there is another table called CityFeatures. We also have a column named CityID in the CityFeature table. This column contains information about feautes of Cities. We can create a Primary Key on the ID column of City table and we can relate this primary key with the Foreing Key on the CityID column of the CityFeatures table.<\/p>\n<p>Thus, if you do not delete all records belonging to the relevant city in the CityFeatures table, you can not delete the record of the relevant city in the city table. This way we can protect our data integrity. Lets make an example practically.<\/p>\n<h2>Primary Key and Foreign Key Example<\/h2>\n<h4>Create City and CityFeatures Tables<\/h4>\n<p>Let&#8217;s create the City and CityFeatures tables with 2 scripts below.<\/p>\n<p>Create the City table with the following script.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nSET ANSI_PADDING ON\nGO\nCREATE TABLE [dbo].[City](\n[ID] [int] IDENTITY(1,1) NOT NULL,\n[CityName] [varchar](250) NULL,\n\u00a0CONSTRAINT [PK_City] PRIMARY KEY CLUSTERED\n(\n[ID] ASC\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) \nON [PRIMARY]\n) ON [PRIMARY]\nGO\nSET ANSI_PADDING OFF\nGO<\/pre>\n<p>Create the CityFeatures table with the below script.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nSET ANSI_PADDING ON\nGO\n\nCREATE TABLE [dbo].[CityFeatures](\n[ID] [int] IDENTITY(1,1) NOT NULL,\n[CityID] [int] NOT NULL,\n[FamousCook] [varchar](50) NULL,\n[FamousDrink] [varchar](50) NULL\n) ON [PRIMARY]\nGO\nSET ANSI_PADDING OFF\nGO<\/pre>\n<h4>Create a Foreing Key<\/h4>\n<p>With the following script, create a foreing key for the CityID column in the CityFeatures table, whose primary column is the ID column in the City table.<\/p>\n<p>As you can see in the Script, we are creating\u00a0 a ForeingKey Constraint in the CityID column in the\u00a0 CityFeatures table. This foreign key&#8217;s primary key is the primary key we created on the ID column of City table.<\/p>\n<pre class=\"lang:default decode:true\">ALTER TABLE [dbo].[CityFeatures]\u00a0 WITH CHECK ADD CONSTRAINT [FK_CityFeatures_City] FOREIGN KEY([CityID])\nREFERENCES [dbo].[City] ([ID])\nGO\nALTER TABLE [dbo].[CityFeatures] CHECK CONSTRAINT [FK_CityFeatures_City]\nGO<\/pre>\n<h4>Insert Data to Tables<\/h4>\n<p>Add a record to the city table with the following script. As you can see, we just inserted value for CityName column. Because, we created ID column of City table as auto increment.. So when each record is inserted, the ID column will increase automatically.<\/p>\n<pre class=\"lang:default decode:true\">INSERT INTO [dbo].[City]([CityName]) VALUES ('Newyork')<\/pre>\n<p>Let&#8217;s try to add a record to CityFeatures as follows.<\/p>\n<pre class=\"lang:default decode:true\">INSERT INTO [dbo].[CityFeatures]([CityID],[FamousCook],[FamousDrink]) VALUES (2,'x','y')<\/pre>\n<p>When we run the above script, we will receive an error like below.<\/p>\n<p><em><span style=\"color: #ff0000;\">The Insert statement conflicted with the FOREIGN KEY constraint FK_CityFeatures_City. The conflict occured in database &#8220;Test&#8221;, table &#8220;dbo.City&#8221;, column &#8216;ID&#8217;.<\/span><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14585 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-29.png\" alt=\"\" width=\"662\" height=\"179\" \/><\/p>\n<p>The reason for the error is that there is no city with 2 IDs in the city table.<\/p>\n<p>When we run the script as follows, we will see that the record has been inserted.<\/p>\n<pre class=\"lang:default decode:true\">INSERT INTO [dbo].[CityFeatures]([CityID],[FamousCook],[FamousDrink]) VALUES (1,'x','y')<\/pre>\n<p>When we try to delete the city table with the following script, we will receive an error like below.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nDROP TABLE [dbo].[City]\nGO<\/pre>\n<p><span style=\"color: #ff0000;\"><em>Could not drop object &#8216;dbo.City&#8217; because it is referenced by a FOREIGN KEY constraint.<\/em><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14587 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-30.png\" alt=\"\" width=\"617\" height=\"191\" \/><\/p>\n<p>In order to delete the city table, we first need to delete the foreign key in the CityFeatures table.<\/p>\n<p>Now, let&#8217;s try to delete the row with ID 1 in the city table by using below script.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nDELETE FROM [dbo].[City] where ID=1\nGO<\/pre>\n<p>The script will fail as below, because there is no record with CityID value 1 in the CityFeatures table.<\/p>\n<p><em><span style=\"color: #ff0000;\">The DELETE statement conflicted with the REFERENCE constraint &#8220;FK_CityFeatures_City&#8221;.<\/span><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14588 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-31.png\" alt=\"\" width=\"619\" height=\"213\" \/><\/p>\n<p>If we first delete the values \u200b\u200bwith ID 1 in the CityFeatures as follows and then run the above script again, delete script will successfully finish.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nDELETE FROM [dbo].[CityFeatures] where CityID=1\nGO<\/pre>\n<p>As you can see in the example, we can guarantee our data integrity by using Primary Key and Foreign Key relationship.<\/p>\n<h3>Can primary keys be null?<\/h3>\n<p>No, primary keys can not be null. We have mentioned in the beginning of the article.<\/p>\n<h3>Can we have primary key on multiple columns?<\/h3>\n<p>Yes, we can create Primary Key by combining multiple columns,\u00a0 This is called the Composite Key.<\/p>\n<h3>Can a Primary Key be a Foreign Key?<\/h3>\n<p>If you want to create one-to-one relationship you can set foreign key as primary key. That is, setting the foreign key column as primary key may be contrary to the foreign key logic. Because usually we use foreign keys for one-to-many relationship.<\/p>\n<h3>Can a Primary Key have multiple Foreign Keys?<\/h3>\n<p>Yes, we can create multiple foreign keys for a primary key. But foreing keys must be on different tables. Because each foreign key reference same primary key value. Therefore, it doesnt make sense creating more than one foreign key for a same primary key. Because values of two foreign key columns will be same. Each foreing key column value that references same primary key can have different values, but it does not make sense too.<\/p>\n<p>Consider our example, ID is our primary key and CityID is our foreign key. Suppose that we have a column CityID2 in CityFeatures table and you want to create a foreing key column on CityID2 that references ID column as primary key. You can do it. But why?<\/p>\n<p>But, it makes more sense to create foreign key column on a different table that reference ID column in the City table.<\/p>\n<h3>Can we update primary key in SQL Server?<\/h3>\n<p>Yes we can update primary keys, but new value of our primary key must require primary key requirements. like uniqueness, not null, etc. Also, when creating the foreign key, you must create it with ON UPDATE CASCADE. If you specify \u201cON UPDATE CASCADE\u201d when creating Foreign Key, this ensures that when there is an update in the column in the primary table, this update is reflected in the table with the foreign key. You may want to read the article &#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2019\/12\/02\/on-delete-cascade-and-on-update-cascade-in-sql-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">ON DELETE CASCADE and ON UPDATE CASCADE in SQL Server<\/a>&#8221; for detailed information.<\/p>\n<p><strong>Important Note:<\/strong> Even if you create foreign key with ON UPDATE CASCADE, be careful that when updating primary key value. Because this cause updating all foreign key values and you may have millions of records in foreign key table.<\/p>\n<p>If you do not create Foreign Key with ON UPDATE CASCADE and try to update primary key column you will receive the below error.<\/p>\n<p><span style=\"color: #ff0000;\"><em>Msg 547, Level 16, State 0, Line 4 <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>The UPDATE statement conflicted with the REFERENCE constraint &#8220;FK_CityFeatures_City&#8221;. The conflict occurred in database &#8220;Test&#8221;, table &#8220;dbo.CityFeatures&#8221;, column &#8216;CityID&#8217;. <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>The statement has been terminated.<\/em><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14677 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-37.png\" alt=\"\" width=\"625\" height=\"212\" \/><\/p>\n<h3>Can we alter\/change primary key data type?<\/h3>\n<p>We can not alter primary key column&#8217;s data type. If you try to alter the table as follows, you will receive the below error.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14683 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-38.png\" alt=\"\" width=\"604\" height=\"222\" \/><\/p>\n<p>You can change primary key data type as follows;<\/p>\n<ul>\n<li>Drop all related foreign keys<\/li>\n<li>Change primary key column&#8217;s data type<\/li>\n<li>Change all related foreign keys column&#8217;s data type<\/li>\n<li>Create foreign key again.<\/li>\n<\/ul>\n<h3>Change Primary Key Data Type Example<\/h3>\n<p>Consider our example. We have a primary key on ID column in City table. Its data type is int. Lets change int to bigint.<\/p>\n<h4>Drop Foreign Key<\/h4>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\n\nALTER TABLE [dbo].[CityFeatures] DROP CONSTRAINT [FK_CityFeatures_City]<\/pre>\n<h4>Change Primary Key Column&#8217;s Data Type<\/h4>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nALTER TABLE [dbo].[City] ALTER COLUMN [ID] bigint not null<\/pre>\n<h4>Change Foreign Key Column&#8217;s Data Type<\/h4>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nALTER TABLE [dbo].[CityFeatures] ALTER COLUMN [CityID] bigint not null<\/pre>\n<h4>Create Foreign Key on same column again<\/h4>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nALTER TABLE [dbo].[CityFeatures]  WITH CHECK ADD  CONSTRAINT [FK_CityFeatures_City] FOREIGN KEY([CityID])\nREFERENCES [dbo].[City] ([ID]) ON UPDATE CASCADE\nGO\nALTER TABLE [dbo].[CityFeatures] CHECK CONSTRAINT [FK_CityFeatures_City]\nGO<\/pre>\n<h3>Can foreign key be null?<\/h3>\n<p>Yes, If you create the foreign key column as null, you can create a Foreign Key on that column and you can insert null value to foreign key column. If you do not create foreign key column as null, you can not insert NULL values into foreign key columns. If you try to insert null values you will receive the error as follows.<\/p>\n<pre class=\"lang:default decode:true\">INSERT INTO [dbo].[CityFeatures]([CityID],[FamousCook],[FamousDrink]) VALUES (null,'x','y')<\/pre>\n<p><span style=\"color: #ff0000;\">Ms<em>g 515, Level 16, State 2, Line 2 <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>Cannot insert the value NULL into column &#8216;CityID&#8217;, table &#8216;Test.dbo.CityFeatures&#8217;; column does not allow nulls. INSERT fails. <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>The statement has been terminated.<\/em><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14592 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-32.png\" alt=\"\" width=\"678\" height=\"177\" \/><\/p>\n<p>To insert null values to foreign key column, you must create table as follows;<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nSET ANSI_PADDING ON\nGO\nCREATE TABLE [dbo].[CityFeatures](\n[ID] [int] IDENTITY(1,1) NOT NULL,\n[CityID] [int] NULL,\n[FamousCook] [varchar](50) NULL,\n[FamousDrink] [varchar](50) NULL\n) ON [PRIMARY]\nGO\nSET ANSI_PADDING OFF\nGO<\/pre>\n<h3>Can a foreign key be part of a primary key?<\/h3>\n<p>Yes, a foreing key be part of a primary key. Lets try it in our example. First delete CityFeatures table and create it again by using the below script.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nSET ANSI_PADDING ON\nGO\nCREATE TABLE [dbo].[CityFeatures](\n[ID] [int] IDENTITY(1,1) NOT NULL,\n[CityID] [int] NOT NULL,\n[FamousCook] [varchar](50) NULL,\n[FamousDrink] [varchar](50) NULL,\nPRIMARY KEY (ID, CityID),\nFOREIGN KEY (CityID) REFERENCES City(ID)\n) ON [PRIMARY]\nGO\nSET ANSI_PADDING OFF\nGO<\/pre>\n<h3>Can foreign key be duplicate?<\/h3>\n<p>Yes, Foreign Keys can be duplicate. They do not have to be unique. You can try to insert same insert value into CityFeatures table.<\/p>\n<pre class=\"lang:default decode:true  \">Declare @count int;\nSET @count=0;\nWhile (@count&lt;10)\nBEGIN\nINSERT INTO [dbo].[CityFeatures]([CityID],[FamousCook],[FamousDrink]) VALUES (1,'x','z')\nSET @count=@count+1\nEND<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14602 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-33.png\" alt=\"\" width=\"671\" height=\"498\" \/><\/p>\n<p>You may want to read the articles below.<\/p>\n<p>&#8220;<a href=\"http:\/\/dbtut.com\/index.php\/2018\/06\/10\/difference-between-clustered-index-and-non-clustered-index\/\" target=\"_blank\" rel=\"noopener noreferrer\">Differences Between Primary Key and Unique Constraint<\/a>&#8220;,<\/p>\n<p>&#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2019\/12\/02\/on-delete-cascade-and-on-update-cascade-in-sql-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">ON DELETE CASCADE and ON UPDATE CASCADE in SQL Server<\/a>&#8221;<\/p>\n<p>&#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2018\/12\/13\/cannot-truncate-table-because-it-is-being-referenced-by-a-foreign-key-constraint\/\" target=\"_blank\" rel=\"noopener noreferrer\">Cannot truncate table because it is being referenced by a FOREIGN KEY constraint<\/a>&#8220;,<\/p>\n<p>&#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2019\/02\/05\/the-constraint-pk_x-is-being-referenced-by-table-x-foreign-key-constraint-fk_x\/\" target=\"_blank\" rel=\"noopener noreferrer\">The constraint \u2018PK_X\u2019 is being referenced by table \u2018X\u2019, foreign key constraint \u2018FK_X\u2019<\/a>&#8220;,<\/p>\n<p>&#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2019\/02\/05\/the-insert-statement-conflicted-with-the-foreign-key-constraint\/\" target=\"_blank\" rel=\"noopener noreferrer\">The INSERT statement conflicted with the FOREIGN KEY constraint<\/a>&#8220;,<\/p>\n<p>&#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2019\/02\/05\/could-not-drop-object-because-it-is-referenced-by-a-foreign-key-constraint\/\" target=\"_blank\" rel=\"noopener noreferrer\">Could not drop object \u201d because it is referenced by a FOREIGN KEY constraint<\/a>&#8221;<\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_285\" class=\"pvc_stats all  \" data-element-id=\"285\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Difference Between Primary Key and Foreign Key You can be find what is Primary Key and Foreign Key and what are differences between Primary Key and Foreing Key below. What is Primary Key? Primary Keys ensures that records in the table are unique. When you create a primary key on a column, a value inserted &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_285\" class=\"pvc_stats all  \" data-element-id=\"285\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":14607,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[7647,7651,7660,7659,7652,7653,7650,2712,7649,7461,7471,7632,7640,7613,7637,7470,7468,7641,7644,7472,7626,1751,7645,7663,7646,315,316,7464,307,311,7467,7481,7630,7629,7631,308,7628,306,7460,7636,313,7661,309,190,7448,7454,7466,7451,7452,7453,7450,7449,7642,310,7648,7654,7662,7658,7655,7656,7657,6443,312,2711,7664,6442,7458,7457,7459,7462,7455,7463,7465,7456,7634,7627,7635,314],"class_list":["post-285","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-alter-primary-key","tag-alter-primary-key-column-data-type-sql-server","tag-alter-primary-key-column-datatype-in-sql-server","tag-alter-primary-key-column-datatype-in-sql-server-2012","tag-alter-primary-key-column-type-in-sql-server","tag-alter-primary-key-data-type-in-sql-server","tag-alter-primary-key-data-type-sql-server","tag-alter-table-alter-column-failed-because-one-or-more-objects-access-this-column","tag-alter-table-primary-key","tag-are-foreign-keys-necessary","tag-can-a-foreign-key-be-part-of-a-primary-key","tag-can-a-primary-key-be-a-composite-key","tag-can-a-primary-key-be-changed","tag-can-a-primary-key-be-null","tag-can-a-primary-key-have-multiple-foreign-keys","tag-can-foreign-key-be-duplicate","tag-can-foreign-key-be-null","tag-can-primary-key-value-be-changed","tag-can-primary-key-values-be-changed","tag-can-primary-keys-be-null","tag-can-we-have-primary-key-on-multiple-columns","tag-cannot-insert-the-value-null-into-column","tag-change-primary-key-data-type","tag-change-primary-key-data-type-example","tag-change-primary-key-data-type-sql-server","tag-check-constraint","tag-composite-key","tag-composite-primary-key","tag-constraint","tag-could-not-drop-object","tag-could-not-drop-object-because-it-is-referenced-by-a-foreign-key-constraint","tag-difference-between-primary-key-and-foreign-key","tag-difference-between-primary-keys-and-foreign-keys","tag-differences-between-primary-key-and-foreign-key","tag-differences-between-primary-keys-and-foreign-keys","tag-fk","tag-foreign-and-primary-key-differences","tag-foreign-key","tag-how-do-you-identify-a-foreign-key","tag-how-do-you-identify-a-primary-key","tag-identity","tag-ms-sql-change-primary-key-data-type","tag-pk","tag-primary-key","tag-primary-key-and-foreign-key","tag-primary-key-and-foreign-key-difference","tag-primary-key-and-foreign-key-example","tag-primary-key-and-foreign-key-examples","tag-primary-key-and-foreign-key-in-sql","tag-primary-key-and-foreign-key-in-sql-with-examples","tag-primary-key-and-foreign-key-together","tag-primary-key-and-foreign-keys","tag-primary-key-values-cannot-be-changed","tag-reference","tag-sql-alter-primary-key","tag-sql-alter-primary-key-column-type","tag-sql-multiple-primary-keys","tag-sql-server-alter-column-data-type-primary-key","tag-sql-server-alter-primary-key-column-type","tag-sql-server-alter-table-column-type-primary-key","tag-sql-server-change-primary-key-column-data-type","tag-the-delete-statement-conflicted-with-the-reference-constraint","tag-the-insert-statement-conflicted-with-the-foreign-key-constraint","tag-the-object-is-dependent-on-column","tag-the-object-is-dependent-on-column-alter-table-alter-column-failed-because-one-or-more-objects-access-this-column","tag-the-update-statement-conflicted-with-the-reference-constraint","tag-what-is-an-example-of-a-foreign-key","tag-what-is-foreign-key-in-dbms","tag-what-is-foreign-key-used-for","tag-what-is-primary-key-and-example","tag-what-is-primary-key-and-foreign-key-with-example","tag-what-is-primary-key","tag-what-is-the-difference-between-primary-key-and-composite-primary-key","tag-what-is-the-primary-and-foreign-key-in-a-database","tag-what-is-the-purpose-of-a-primary-key-in-access","tag-what-is-the-relation-between-primary-key-and-foreign-key","tag-which-field-or-fields-should-be-designated-as-the-primary-key","tag-with-check-add-constraint"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Primary Key and Foreign Key - Database Tutorials<\/title>\n<meta name=\"description\" content=\"What is Primary Key and Foreign Key\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Primary Key and Foreign Key - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"What is Primary Key and Foreign Key\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-14T21:02:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-09T14:27:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png\" \/>\n\t<meta property=\"og:image:width\" content=\"480\" \/>\n\t<meta property=\"og:image:height\" content=\"338\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbtut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbtut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\"},\"author\":{\"name\":\"dbtut\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\"},\"headline\":\"What is Primary Key and Foreign Key\",\"datePublished\":\"2018-06-14T21:02:53+00:00\",\"dateModified\":\"2020-01-09T14:27:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\"},\"wordCount\":1681,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png\",\"keywords\":[\"alter primary key\",\"alter primary key column data type sql server\",\"alter primary key column datatype in sql server\",\"alter primary key column datatype in sql server 2012\",\"alter primary key column type in sql server\",\"alter primary key data type in sql server\",\"alter primary key data type sql server\",\"ALTER TABLE ALTER COLUMN failed because one or more objects access this column\",\"alter table primary key\",\"Are foreign keys necessary?\",\"Can a foreign key be part of a primary key?\",\"Can a primary key be a Composite Key?\",\"can a primary key be changed\",\"can a primary key be null\",\"Can a Primary Key have multiple Foreign Keys\",\"Can foreign key be duplicate?\",\"Can foreign key be null?\",\"can primary key value be changed\",\"can primary key values be changed\",\"Can primary keys be null?\",\"Can we have primary key on multiple columns?\",\"Cannot insert the value NULL into column\",\"change primary key data type\",\"Change Primary Key Data Type Example\",\"change primary key data type sql server\",\"CHECK CONSTRAINT\",\"Composite Key\",\"composite primary key\",\"constraint\",\"Could not drop object\",\"Could not drop object because it is referenced by a FOREIGN KEY constraint.\",\"Difference Between Primary Key and Foreign Key\",\"difference between primary keys and foreign keys\",\"differences between primary key and foreign key\",\"differences between primary keys and foreign keys\",\"FK\",\"Foreign and Primary Key Differences\",\"Foreign Key\",\"How do you identify a foreign key?\",\"How do you identify a primary key?\",\"identity\",\"ms sql change primary key data type\",\"PK\",\"primary key\",\"primary key and foreign key\",\"primary key and foreign key difference\",\"Primary Key and Foreign Key Example\",\"primary key and foreign key examples\",\"primary key and foreign key in sql\",\"primary key and foreign key in sql with examples\",\"primary key and foreign key together\",\"primary key and foreign keys\",\"primary key values cannot be changed\",\"REFERENCE\",\"sql alter primary key\",\"sql alter primary key column type\",\"sql multiple primary keys\",\"sql server alter column data type primary key\",\"sql server alter primary key column type\",\"sql server alter table column type primary key\",\"sql server change primary key column data type\",\"The DELETE statement conflicted with the REFERENCE constraint\",\"The Insert statement conflicted with the FOREIGN KEY constraint\",\"The object is dependent on column\",\"The object is dependent on column. ALTER TABLE ALTER COLUMN failed because one or more objects access this column.\",\"The UPDATE statement conflicted with the REFERENCE constraint\",\"What is an example of a foreign key?\",\"What is foreign key in DBMS?\",\"What is foreign key used for?\",\"What is primary key and example?\",\"What is primary key and foreign key with example?\",\"What is Primary Key?\",\"What is the difference between primary key and composite primary key?\",\"What is the primary and foreign key in a database?\",\"What is the purpose of a primary key in access?\",\"What is the relation between primary key and foreign key?\",\"Which field or fields should be designated as the primary key?\",\"WITH CHECK ADD CONSTRAINT\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\",\"name\":\"What is Primary Key and Foreign Key - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png\",\"datePublished\":\"2018-06-14T21:02:53+00:00\",\"dateModified\":\"2020-01-09T14:27:42+00:00\",\"description\":\"What is Primary Key and Foreign Key\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png\",\"width\":480,\"height\":338},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is Primary Key and Foreign Key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\",\"name\":\"dbtut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"caption\":\"dbtut\"},\"description\":\"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.\",\"sameAs\":[\"http:\/\/NurullahCAKIR\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/dbtut\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Primary Key and Foreign Key - Database Tutorials","description":"What is Primary Key and Foreign Key","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/","og_locale":"en_US","og_type":"article","og_title":"What is Primary Key and Foreign Key - Database Tutorials","og_description":"What is Primary Key and Foreign Key","og_url":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/","og_site_name":"Database Tutorials","article_published_time":"2018-06-14T21:02:53+00:00","article_modified_time":"2020-01-09T14:27:42+00:00","og_image":[{"width":480,"height":338,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png","type":"image\/png"}],"author":"dbtut","twitter_card":"summary_large_image","twitter_misc":{"Written by":"dbtut","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/"},"author":{"name":"dbtut","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408"},"headline":"What is Primary Key and Foreign Key","datePublished":"2018-06-14T21:02:53+00:00","dateModified":"2020-01-09T14:27:42+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/"},"wordCount":1681,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png","keywords":["alter primary key","alter primary key column data type sql server","alter primary key column datatype in sql server","alter primary key column datatype in sql server 2012","alter primary key column type in sql server","alter primary key data type in sql server","alter primary key data type sql server","ALTER TABLE ALTER COLUMN failed because one or more objects access this column","alter table primary key","Are foreign keys necessary?","Can a foreign key be part of a primary key?","Can a primary key be a Composite Key?","can a primary key be changed","can a primary key be null","Can a Primary Key have multiple Foreign Keys","Can foreign key be duplicate?","Can foreign key be null?","can primary key value be changed","can primary key values be changed","Can primary keys be null?","Can we have primary key on multiple columns?","Cannot insert the value NULL into column","change primary key data type","Change Primary Key Data Type Example","change primary key data type sql server","CHECK CONSTRAINT","Composite Key","composite primary key","constraint","Could not drop object","Could not drop object because it is referenced by a FOREIGN KEY constraint.","Difference Between Primary Key and Foreign Key","difference between primary keys and foreign keys","differences between primary key and foreign key","differences between primary keys and foreign keys","FK","Foreign and Primary Key Differences","Foreign Key","How do you identify a foreign key?","How do you identify a primary key?","identity","ms sql change primary key data type","PK","primary key","primary key and foreign key","primary key and foreign key difference","Primary Key and Foreign Key Example","primary key and foreign key examples","primary key and foreign key in sql","primary key and foreign key in sql with examples","primary key and foreign key together","primary key and foreign keys","primary key values cannot be changed","REFERENCE","sql alter primary key","sql alter primary key column type","sql multiple primary keys","sql server alter column data type primary key","sql server alter primary key column type","sql server alter table column type primary key","sql server change primary key column data type","The DELETE statement conflicted with the REFERENCE constraint","The Insert statement conflicted with the FOREIGN KEY constraint","The object is dependent on column","The object is dependent on column. ALTER TABLE ALTER COLUMN failed because one or more objects access this column.","The UPDATE statement conflicted with the REFERENCE constraint","What is an example of a foreign key?","What is foreign key in DBMS?","What is foreign key used for?","What is primary key and example?","What is primary key and foreign key with example?","What is Primary Key?","What is the difference between primary key and composite primary key?","What is the primary and foreign key in a database?","What is the purpose of a primary key in access?","What is the relation between primary key and foreign key?","Which field or fields should be designated as the primary key?","WITH CHECK ADD CONSTRAINT"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/","url":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/","name":"What is Primary Key and Foreign Key - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png","datePublished":"2018-06-14T21:02:53+00:00","dateModified":"2020-01-09T14:27:42+00:00","description":"What is Primary Key and Foreign Key","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-34.png","width":480,"height":338},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"What is Primary Key and Foreign Key"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408","name":"dbtut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","caption":"dbtut"},"description":"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.","sameAs":["http:\/\/NurullahCAKIR"],"url":"https:\/\/dbtut.com\/index.php\/author\/dbtut\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/14607"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}