QTP Forum


Join the forum, it's quick and easy

QTP Forum
QTP Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Poll
Keywords

Latest topics
» composite primary key
composite primary key EmptyThu Jun 19, 2014 11:31 am by thomasdfg

» How to identify the object when it is dynamically changing behavior
composite primary key EmptyWed Jun 18, 2014 6:37 pm by thomasdfg

» Patches for QTP 10, 11, 11.5
composite primary key EmptyWed Jun 18, 2014 6:04 pm by thomasdfg

» Retrieving data from Txt file into datatable
composite primary key EmptyWed Jun 18, 2014 5:32 pm by thomasdfg

» VB Script to count number of links in a web page.
composite primary key EmptyWed Jun 18, 2014 4:51 pm by thomasdfg

» Customized HTML reports in QTP
composite primary key EmptyWed Jun 18, 2014 4:42 pm by thomasdfg

» how to print values into a field of a web page, from a data table in qtp?
composite primary key EmptyWed Jun 18, 2014 4:37 pm by thomasdfg

» How to delete cookies using QTP?
composite primary key EmptyWed Jun 18, 2014 4:30 pm by thomasdfg

» When UFT Does Not Identify an Object
composite primary key EmptyWed Jun 18, 2014 4:23 pm by thomasdfg

April 2024
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar

Affiliates
free forum


composite primary key

3 posters

Go down

composite primary key Empty Re: composite primary key

Post by thomasdfg Thu Jun 19, 2014 11:31 am

A composite key has more than one attribute (field). In this example we store details of tracks on albums - we need to use three columns to get a unique key - each album may have more than one disk - each disk will have tracks numbered 1, 2, 3...
The primary key must be different for each row of the table. The primary key may not contain a null.
thomasdfg
thomasdfg

Posts : 11
Join date : 2014-06-18
Age : 39
Location : Hyderabad

Back to top Go down

composite primary key Empty Re: composite primary key

Post by Gajre Sun Nov 25, 2012 4:20 pm

When you use the multiple-column
constraint format, you can create a composite key. A composite
key
specifies multiple columns for a primary-key or foreign-key
constraint.

The below example creates two tables. The first table has
a composite key that acts as a primary key, and the second table has
a composite key that acts as a foreign key.

CREATE TABLE accounts (
acc_num INTEGER,
acc_type INTEGER,
acc_descr CHAR(20),
PRIMARY KEY (acc_num, acc_type));

CREATE TABLE sub_accounts (
sub_acc INTEGER PRIMARY KEY,
ref_num INTEGER NOT NULL,
ref_type INTEGER NOT NULL,
sub_descr CHAR(20),
FOREIGN KEY (ref_num, ref_type) REFERENCES accounts
(acc_num, acc_type));


In this example, the foreign key of the sub_accounts table, ref_num and ref_type,
references the composite key, acc_num and acc_type,
in the accounts table. If, during an insert or update, you
tried to insert a row into the sub_accounts table whose value
for ref_num and ref_type did not exactly correspond
to the values for acc_num and acc_type in an existing
row in the accounts table, the database server would return
an error.

A referential constraint must have a one-to-one relationship
between referencing and referenced columns. In other words, if the
primary key is a set of columns (a composite key), then the foreign
key also must be a set of columns that corresponds to the composite
key.

Because of the default behavior of the database server,
when you create the foreign-key reference, you do not need to reference
the composite-key columns (acc_num and acc_type) explicitly.
You can rewrite the references section of the previous example as
follows:

FOREIGN KEY (ref_num, ref_type) REFERENCES accounts
Gajre
Gajre
Admin

Posts : 37
Join date : 2012-06-17
Age : 41
Location : Hyderabad

https://qtpelearning.forumotion.com

Back to top Go down

composite primary key Empty composite primary key

Post by sriharish2 Fri Nov 23, 2012 9:18 pm

What is composite primary key?
Question

sriharish2

Posts : 8
Join date : 2012-10-31

Back to top Go down

composite primary key Empty Re: composite primary key

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum