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 > Report friendly database design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-08, 16:28
mr_tinkles mr_tinkles is offline
Registered User
 
Join Date: Jan 2008
Posts: 2
Report friendly database design

Hello everyone. I'm a relative novice when it comes to databases and am having trouble designing a particular part of a database which I'll now describe.
Basically I'm storing information on equipment which is hired out. It comes in three broad categories:

Personnel ( Electricians, plumbers etc )
Plant ( Things like generators, cement mixers etc )
Vehicles

The system using the database needs to be able to access any item with a unique id so I've also created three tables and a crude sort of lookup table.

personnel ( id*, created, modified, description, cost_per_hour, ... )
plant ( id*, created, modified, description, on_hire, date_of_purchase, ... )
vehicle ( id*, created, modified, description, on_hire, date_of_purchase, ... )
lookup ( id, type )

The tables all share a common sequence for id generation

To find what I need I initially do a lookup on this lookup table and then query the relevant table based on the type. This setup was working ok until I needed to create reports and it seems it's grossly inadequate for that. At present the only workable solution I can think of is to combine them all into one big table which just doesn't seem right to me.

Basically then I'm hoping someone with more experience than me can suggest a better design. I'm reading up on databases as fast as I can but I'm under pressure to get this working so any help would be very much appreciated!

If I've left anything out please just ask and I'll get back asap.

Thanks in advance...
Reply With Quote
  #2 (permalink)  
Old 01-29-08, 17:26
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Sounds like you are using Oracle? Your solution may be code-specific, so you might want to post this question in the Oracle forum.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #3 (permalink)  
Old 01-30-08, 16:46
mr_tinkles mr_tinkles is offline
Registered User
 
Join Date: Jan 2008
Posts: 2
Thanks for your reply. I'm using Postgresql for the database. I don't think the design issue is database specific to be honest. There have been developments since I posted however and it seems the design I initially outlined is no longer valid so feel free to lock / delete this thread. Once again thanks for your response
Reply With Quote
  #4 (permalink)  
Old 01-31-08, 15:11
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
PostgreSQL supports an object oriented feature called table inheritance, which may 'fit the bill' for your situation.

You could define a single, common table, containing all the common fields for your three tables, as well as the 'type' identifier. (I would also add an object_type lookup table, with a TypeID and a TypeDescription field.)

After the first, base table is defined, add the the three specific table, each containing only the fields unique to the object in question.

Ref this thread for a description of table inheritance, as well as the postgresql documentation for details of table inheritance.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

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