• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple tables or single table

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Can someone suggest me please whether to create multiple tables or it is ok if we create just one table.

I have a situation where I am storing persons' data in multiple tables.I was just wondering can I use one table instead to store the information about a person?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you are storing data in a relational database then the concept of normalisation must come in to play here ...

if storing all person data in one table will mean there will be redundant data then this should be avoided.

classic example is Employees and Departments;

an Employee may work in only one Department
but a Department may employ many Employees

so we make one table for Employees and one table for Departments - otherwise for employees working in the same department we will end up storing the department name many times (redundant data).



more difficult to maintain data integrity in this case - when the dept name changes need to find all occurences of the dept name - dept name may end up coded slightly differently for different emps (IT, I.T, it, ...).

Depends on your data - if data in the tables is related in a one-to-one relationship then could store in one table.

Hope this helps.
 
Suhem Programmer
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Craig,

Thanks a lot for the reply. But all the tables have one to one relationship. So is that fine if I put them all together in one table?

I am sorry about not mentioning it before, I am using relational detabase(oracle 10g)

Thanks,
Hemali
 
Craig Collins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, perhaps you could describe the data in the tables, i.e. what entities the tables represent, and the attributes in each table.

we have an Employee table presumably with Name, Date of Birth ...
but what are the other tables?
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would still do it as a normalized table as suggested.
Currently you have a 1 to 1, but users like to change things.
It will make modification easier in the future if you use normalized tables.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic