Do I need to mention primary key for each table

+1 vote
Hey,

I am bit confused about primary key and constraints in database. Is there any rule that for each table I need to use primary key or foreign key?
Jul 4, 2019 in Database by Pritha
250 views

1 answer to this question.

+1 vote

Hi Pritha,

First, there is no hard and fast rule to add constraint in your table But we use constraint in our table to reduce data repetition and redundancy in our table.

And if you want to fetch one particular data that time primary key will help you to get that row only.

I hope, this will help you out

Thank you,

answered Jul 4, 2019 by sampriti
• 1,120 points

Related Questions In Database

0 votes
1 answer

Which one is suitable for real time big database- Primary Key or Unique Index?

What is a unique index? A unique index ...READ MORE

answered Oct 12, 2018 in Database by Frankie
• 9,810 points
640 views
0 votes
1 answer

Can I have multiple primary keys in a single table?

A Table can have a Composite Primary Key which ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,810 points
2,100 views
0 votes
1 answer

Things I need to consider before installing MSSQL on Linux

SQL server on Linux is pretty new ...READ MORE

answered Mar 17, 2019 in Database by Mohor
166 views
0 votes
1 answer

How to sort the data in sql ?

Hi Akash,  If you want to sort ...READ MORE

answered May 29, 2019 in Database by sampriti
• 1,120 points
245 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
249 views
0 votes
1 answer

Find values in a comma separated string in a MySQL query

You can add commas to the left and ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,380 points
10,652 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,380 points
1,530 views
0 votes
1 answer

Do I need to add primary key in each and every table?

Hi Shraddha, You have a doubt to add ...READ MORE

answered May 29, 2019 in Database by sampriti
• 1,120 points
246 views
0 votes
1 answer

What is the best way to fetch data from table?

Hey Shraddha, I understand your doubts about fetching ...READ MORE

answered May 25, 2019 in Database by sampriti
• 1,120 points
804 views