If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Designing Database Tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-06, 07:27
chamalsl chamalsl is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
Designing Database Tables

Hi,

Let's assume we have to develop an application for a bank.

There are different types of Accounts in a Bank. ex: Fixed Deposit Accounts, Current Accounts, Savings Accounts
There is also the possibility of adding new account types.

How should we design the database.

Have one Table to store common account data and three more tables to store data of 3 account types?
But I will have to create a new table and amend my code to access new table if I add another type of account.

Another method I thought of is to use a table to store configuration data.

AccountConfiguation Table:

Account Type Column Id Column Desc
=========== ====== =========

And add column details for each table.

Then have one main table to save details of all 3 account types.

AccountDetails Table

AccountID Column Id Data
========= ========= =====

Please help me to identify the best method or is there any other way.


Best Regards,
Chamal.
Reply With Quote
  #2 (permalink)  
Old 06-26-06, 07:40
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
You are in danger of straying into the big mistake that is Entity-Attribute-Value (EAV). You don't want to go there.

Yes, you'd have to amend your code if you introduced a new account type. Surely you'd have to do that anyway if it had new attributes?

If there aren't too many account types or too many columns altogether, you could simplify to a single table with all common and type-specific columns. The type-specific columns would be NULL for other types and check constraints would be used to ensure the appropriate columns were used for the account type.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 06-26-06, 07:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
do a search for subtype/supertype
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On