Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data dictionary

Former Member
0 Likes
1,397

hi experts,

what is mean by primary key in the data base table ? what is the main purpose of that? with out primary what happens.

in custom table how many primary keys we can put maximum? at what basis we have to take primary key?

give me the answer briefly with small understanding ex.

thanks.

12 REPLIES 12
Read only

Former Member
0 Likes
1,361

http://databases.about.com/cs/administration/g/primarykey.htm

Note:

please try to search in google these are not sap questions these r fundamentals of DATAbase.

Read only

Former Member
0 Likes
1,361

Hi

Go through the link given below :

http://help.sap.com/saphelp_nw04/helpdata/en/b3/b238bfd13a8f408958d70a6989d001/content.htm

Hope it will help you.

Thanks & Regards

Nikunj Shah

Read only

Former Member
0 Likes
1,361

Hi,

Check out this link for Primary Keys. You can define 16 primary keys in a table.

http://help.sap.com/saphelp_nw04s/helpdata/en/3c/384c4005a99523e10000000a1550b0/frameset.htm

Thanks

Nayan

Reward if useful

Read only

Former Member
0 Likes
1,361

hi primary key is the basic element for the data base table for getting relation between the tables .....with out giving primary key there is a performace issue when reading the data ..

you can test this select statement in the st05 tcode by specifying the primary key ....and not specifying the primary key...

this plays a major role while using the read statement

Read only

Former Member
0 Likes
1,361

Hi,

Primary key is the unique identifier to specify / select a single row in the entire table.

With out primary keys it will be difficult to identify a single object.

We can have a single Primary key and it may be a collection of some fields.

For ex, emp name, location, practice collectively can be a primary key in the table COMPANY.

or the single field empno can be the primary key.

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/c00047...

regards,

teja.

Read only

Former Member
0 Likes
1,361

hi,

In a table you can have many number of records, so to maintian the uniquenss of the record we manintain the primary key relation. so now in a table if you check the primary key check box for the first field . the values of the field in that table is unique, you cannto duplicate values in to that field , similarly if you keep the first tow fields as primary ,there combination will be unique.

you can have any number of primary key combnation. important thing is a table should have minimun one primary key

thanks & regards

kumar

Read only

Former Member
0 Likes
1,361

hi.

while creating a table u must give one field as primary key either mandt field or any user defined field.

with out primary key u cannot create the table or the table wil not be activated.u wil get an error.

u can assign max up to 20 primary keys are allowed not more than that.

explanation:

Q:why we are assigning primary key?

A:generally we give primary key to identify uniquely.

example:bank account number.

many people wil have account numbers but how to identify them so we give primary key as bank acnumber as key field so it is easy to identify.

u can also give primary key to name also.it checks for both and then updates in the database table.

Read only

Former Member
0 Likes
1,361

hi ,

here are the answers to your questions:

Q1.What is mean by primary key in the data base table ?

ans:

In relational database design, a unique key or primary key is a candidate key to uniquely identify each row in a table. A unique key or primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or combination of values) in those columns. Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.

Q2. what is the main purpose of that?

ans: main purpose of using primary key is to ensure the uniqueness of data tuple in a datbase table.

Q3.with out primary what happens.

ans: two or more data may be stored in the same table causing data redundency and inconsistancy.

Q4.in custom table how many primary keys we can put maximum? 16

Q5.at what basis we have to take primary key?

intialy take it on the basis of your raugh database design.then optimise it by using normalisation

Edited by: Anirban Bhattacharjee on Jun 24, 2008 7:17 AM

Read only

Former Member
0 Likes
1,361

Hi Shirish.

Primary Key:

A table has one or more key fields, these fields are defined as primary key(s).

e.g: In table, SPFLI for flight details: Field with checkbox under key selected are termed as key fields and hence, CARRID & CONNID are termed as primary key fields.

Purpose of a Primary Key:

The values of these key fields uniquely identify a table entry.

uniquely means - existing as the only one.

Which means it prevents duplicate entries.

e.g: By their means other data pertaining to fields in different database tables can be linked as they have common characteristics.
Like CARRID and CONNID in SPFLI table can be linked to SFLIGHT & SBOOK database tables as these fields are primary key fields in those respective tables.

If there is no primary key:

The major issue is that it will give a short dump.

As stated earlier, Without a primary key it will be very difficult to establish a link between multiple tables and also we will not be able to define any foreign key relationships.

Also,it will be difficult to fetch the detailed information of the required data as these fields are the main fields which decide the kind of data fetched.

E.g: If we do not enter CARRID & CONNID as key fields, they all the records from the database will be fetched and not the required records. This will increase load on Database and increase the fetching time which causes a performance issue.

Maximum number of primary keys:

It's your wish you can put as many number of primary keys.

But, If you put all primary keys, Recalling the earlier sentence

Primary keys prevent duplicate entries, hence for example

In case of fields like FLDATE, CURRENCY, LUGGWEIGHT, PRICE, etc only one record pertaining to that entry will be fetched and rest will be not fetched. So, you can understand the situation.

Basis of primary key selection:

Primary key must be a field rather key field which will be able to cover the information about the whole selection or entry.

Which means that whenever a key field passed as a parameter must satisfy the requirement of fetching records without much load on database and avoiding complexity.

E.g: If we pass Carrid and Connid, as parameters in any program. It must display/fetch records pertaining to that flight name and flight connection number. But, if only carrid is given it will fetch all the records pertaining to (say) Lufthansa which add more load to the database.

Reward points if you find this information usefull.

Regards Harsh.

Read only

Former Member
0 Likes
1,361

sory folks

Please ignore this post

Read only

Former Member
0 Likes
1,361

hi,

primary key is to identify Uniquely a particular record of a DB table.there can be max 16 pirmary key in a table.

refer to the link below,

http://help.sap.com/saphelp_nw04/helpdata/en/b3/b238bfd13a8f408958d70a6989d001/content.htm

with luck,

pritam.

Read only

Former Member
0 Likes
1,361

Hi,

The primary key of a relational table uniquely identifies each record in the table. It can either be a normal attribute that is guaranteed to be unique (such as Social Security Number in a table with no more than one record per person) or it can be generated by the DBMS .

Primary keys may consist of a single attribute or multiple attributes in combination.

Imagine we have a student records database that contains three tables. The first table, STUDENTS, contains a record for each student at the university. The second table, CLASSES, contains a record for each class session offered.

The third table, ENROLLMENT, contains student enrollment records (e.g. each record represents a single student enrolling in a single course). There would be multiple records for each student (representing all the classes that student is enrolled in) and multiple records for each class session (representing all the students enrolled in that class).

A student's unique student ID number would be a good choice for a primary key in the STUDENTS table. The student's first and last name would not be a good choice, as there is always the chance that more than one student might have the same name.

Regards,

Rajitha.