954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

weak entity representation

in the diagram provided in the attachment.i have created a table for the entity loan and now i am facing difficulty in creating a table for payment.i know that payment is the dependent entity.is the following way of creating a table correct????

create table payment(
payment_number int,
payment_date date,
payment_amount int,
loan_number int,
primary key(loan_number,payment_number),
foreign key(loan_number)references loan(loan_number)
);

Attachments Doc1.docx (164.29KB)
starkk
Newbie Poster
15 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Yes.
I wonder, though, why you allow multiple payment_numbers. Make them unique and the primary key. In MySQL:

create table payment(
payment_number integer not null primary key,
payment_date date not null,
payment_amount float not null,
loan_number integer not null,
foreign key(loan_number) references loan(loan_number)
);
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

As payment is dependent attribute,we should make composite primary key(loan_number,payment_number)and loan_number will be the foreign key.pls correct me if i am wrong

starkk
Newbie Poster
15 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You