Computer Science, asked by rajpalyadav44, 1 year ago

difference between primary key and foreign key???

Answers

Answered by Toshika654
3

hi

buddy ✌️✌️✌️✌️

❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️

Primary Key and Unique Key are Entity integrity constraints

Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist and no null values are entered.

Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values. (In oracle one null is not equal to another null).

KEY or INDEX refers to a normal non-unique index. Non-distinct values for the index are allowed, so the index may contain rows with identical values in all columns of the index. These indexes don't enforce any structure on your data so they are used only for speeding up queries.

UNIQUE refers to an index where all rows of the index must be unique. That is, the same row may not have identical non-NULL values for all columns in this index as another row. As well as being used to speed up queries, UNIQUE indexes can be used to enforce structure on data, because the database system does not allow this distinct values rule to be broken when inserting or updating data. Your database system may allow a UNIQUE index on columns which allow NULL values, in which case two rows are allowed to be identical if they both contain a NULL value (NULL is considered not equal to itself), though this is probably undesirable depending on your application.

PRIMARY acts exactly like a UNIQUE index, except that it is always named 'PRIMARY', and there may be only one on a table (and there should always be one; though some database systems don't enforce this). A PRIMARY index is intended as a way to uniquely identify any row in the table, so it shouldn't be used on any columns which allow NULL values. Your PRIMARY index should always be on the smallest number of columns that are sufficient to uniquely identify a row. Often, this is just one column containing a unique auto-incremented number, but if there is anything else that can uniquely identify a row, such as "countrycode" in a list of countries, you can use that instead.

FULLTEXT indexes are different to all of the above, and their behaviour differs more between database systems. Unlike the above three, which are typically b-tree (allowing for selecting, sorting or ranges starting from left most column) or hash (allowing for selection starting from left most column), FULLTEXT indexes are only useful for full text searches done with the MATCH() / AGAINST() clause.

❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️

Brain list pls❤️❤️❤️

@toshika

#follow me#

Answered by Nєєнα
38

Explanation:

Primary key:::::

♥ A specific choice of a minimal set of attributes or columns that uniquely specifies a topic or row in a table

♥ Related to a single table

♥ value cannot be null

♥ cannot have duplicate values

Foreign key:::::

♥ A feild or collection of fields in one table that uniquely identifies a row of another table or same table

♥ related to two tables

♥ value can be null

♥ can have duplicate values

hope it helps u.....❣️

Similar questions