Mapping to an and the other to map several in a single table

Hi all

I am asked to design a banking application, I the CUSTOMER table where client information is stored. I have a table of ACCOUNT where account information is stored.
Now a customer can start all 3 types of accounts. (Current account, savings account and FD (deposits))

A customer can have - > only one record chequing account, but may have several FD account. How do implement us this using integrity constraints?



CUSTOMER-> Cust_name, Cust_phone, Cust_id (PK), Cust_address table
ACCOUNT-> AccountNo, Acc_type, Cust_id table

Your response is greatly appreciated.

Thank you
Yvette

You may need to create a UNIQUE function based index. It works for you.

create table customer_1 (Cust_id integer primary key, Cust_name varchar2(100), Cust_phone number, Cust_address varchar2(100))
/
create table account_1 (AccountNo integer primary key, Acc_type varchar2(100),Cust_id integer references customer_1(cust_id))
/
create unique index account_idx on account_1 (cust_id, decode(acc_type,'CA',acc_type, 'SA', acc_type, 'FD', 'FD' || accountno))
/
insert into customer_1 (cust_id, cust_name, cust_phone, cust_address) values (1, 'karthick', 0, 'x')
/
insert into account_1 (accountno, acc_type, cust_id) values(1, 'CA', 1)
/
insert into account_1 (accountno, acc_type, cust_id) values(2, 'SA', 1)
/
insert into account_1 (accountno, acc_type, cust_id) values(3, 'FD', 1)
/
insert into account_1 (accountno, acc_type, cust_id) values(4, 'FD', 1)
/
insert into account_1 (accountno, acc_type, cust_id) values(5, 'FD', 1)
/

Tags: Database

Similar Questions

Maybe you are looking for

  • do not only shows inbox, deleted, sent, trash, archive, junk. don't know how to recover these

    trying to get into the emails and only goes to the Inbox. no drop-down menu bar showing the basket, sent, archives, spam, spam. Please let me know how to fix this problem.

  • Sound won't speakers when headphones are pulled out.

    When I watch the video in flash and connect my headset, I can not everything in FF without having to restart the program. And when I close the process is still running. But when I stop the process in Task Manager, then start it again I can hear the s

  • XControl in secondary seems to block FP

    Hi all I want to view and modify the data of a class LV and its child classes (such as object graph with points, boxes, circle... as child classes). By running the main class VI can change everything and various controls and indicators will be visibl

  • Help - just sync Sansa Fuze 4 GB and not selected folder names

    I just sync Sansa Fuze 4 my wife Go with Windows Media Player and folder names are not preserved. It's the folder view using the artist name and it is not how the songs were - they were on the PC as "Classic country" etc. That's happened? I have one

  • Need to download MS Office

    I had to replace my hard drive. Now I am rebuilding my system. I bought my pre-installed with MS Office System. When I go to Dell downloads, MS Office is not on the list of downloads for my system. How can I download my new copy of MS Office?