Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Since using forums in my early days 10 years ago in CompuServe, one had to log back on and sometimes wait days for a response. Now I get a response e-mailed to me which I can click a link and go right back to exactly where My post was..."

Geography

Where in the world do Tek-Tips members come from?
hoojar (Programmer)
1 Jul 09 7:04
Hi,

I'm trying to learn C# and OO. I normally use PHP/MYSQL and have dabbled with vb.net.

my question is, can I still use relational databases with OO or do I need to learn a new design method for my db's as well? and if I can use a relational DB how do i get from my DB design to my class design?

thanks.
vb5prgrmr (Programmer)
1 Jul 09 7:51
>my question is, can I still use relational databases with OO
Yes. As databases are normalized to 3rd normal form, the data is naturally grouped for functionality. Like accounts recievable, customers, suppliers, accounts payable, employees and so on.

>and if I can use a relational DB how do i get from my DB design to my class design?

User Interface
^^^^^^^^^^^^^^^^^^^
Object Oriented Fuctionality
^^^^^^^^^^^^^^^^^^^
Normalized Database

Your OO Functionality should "naturally" sit upon the underlying data...


Good Luck
hoojar (Programmer)
1 Jul 09 8:16
thanks vb5prgrmr, its a releif to know that.

so for example, in my DB if I have several tables making up an employee such as address, jobrole_details, logon_details, etc would they be one class each or would they be all pulled together into one class?
jmeckley (Programmer)
1 Jul 09 8:35
relational databases  to OOP... research the concept of ORM Object Relational Mapper. This type of framework is responsible for transforming relational data into business objects (which usually contain behavior).

php has PEAR, if I recall correctly.  in .net the leading ORM is NHibernate (OSS). Castle.ActiveRecord (OSS) also exists for .net. If you have a small budget you may also want to consider LLBL Gen Pro ($).

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

vb5prgrmr (Programmer)
1 Jul 09 20:30
True OO... each would be a class/object with another object sitting on top if one wanted to say review all such pertinent data...

Just a side note of warning. With OO it is very easy to build objects upon objects on top of more objects which could lead to object confusion. So care should be taken when designing yor objects.


Good Luck

 
jmeckley (Programmer)
2 Jul 09 8:58

Quote:

With OO it is very easy to build objects upon objects on top of more objects which could lead to object confusion.
this is a dangerous statement. the system needs to be flexible enough to fulfill the requirements, but no over complicated. Finding this balance is an art. The best guiding principles I found are the SOLID design patterns. thread678-1549983: Great Aggregation on SOLID Design Principles

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

vb5prgrmr (Programmer)
2 Jul 09 9:09
>Dangerous statement?

Dangerous Outcome! If one is not careful. Just a fact of life in the OO world.
ITPerforms (Vendor)
22 Jul 09 11:51
The Relational Database Model fits in very well with Object Oriented Design. Infact that is exactly what OOP technology is all about - grouping common functionality into classes which usually sit on top of a relational database engine. In multi-tier systems, this would usually be the middle tier that would communicate with the database and then pass data to the front end of the system.
jmeckley (Programmer)
22 Jul 09 12:00

Quote:

Infact that is exactly what OOP technology is all about - grouping common functionality into classes which usually sit on top of a relational database engine.
grouping common functionality; yes. whether an application uses a db or not is irrelevant.

Quote:

The Relational Database Model fits in very well with Object Oriented Design.
quite the contrary. Have to seen complexity of ORM frameworks? This is the very problem they solve. objects contain behavior, databases contain data. getting the 2 to play nice, from scratch, is no easy task.

now if you treat your objects as tables then yes there is a 1:1 mapping. But if that is the case you would save time using the DataSet concept/objects in the .net framework.

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

Helpful Member!  stevexff (Programmer)
22 Jul 09 15:19

Quote (arcdogl):

how do i get from my DB design to my class design?
Unless you are in the unfortunate position of already having a database, you don't. Think of the database merely as a way of persisting your classes while they are not being used. The question you need to ask is "how do I get to my DB design from my class model", and as Jason has already noted there are several ORMs that will do the heavy lifting for you.

Steve

"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)

jmeckley (Programmer)
22 Jul 09 15:21
@stevexff
well said.

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

Diancecht (Programmer)
28 Jul 09 3:00
I must disagree.

In the world I live, databases exists, they cannot be changed and they're not in 3rd normal form, as it's fairly ineficient in several scenarios.

So my OO design is just for the application, from a logical or functional point of view. And after that, I'll think on the way to couple things.

Futhermore, there's no 1:1 relationship between a database and an application, so OO and database design must be independent as they will vary on their own.

 

Cheers,
Dian

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close