Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

General C++/Database Programming Question

Posted on 1998-08-08
2
Medium Priority
?
250 Views
Last Modified: 2010-04-02
I am using SQL Server 6.5, Visual C++, and COM to tackle a personal project.  I understand the use of Primary Keys, Foreign Keys nad other referential integrity mechanisms when designing a database.  But, in the COM world, where the business logic is often sandwiched between the data layer and the application layer, are referential integrity mechanisms commonly used?
My direct point is that it seems redundant for me to implement foreign keys in a SQL database design only to code the knowledge of these table relationships into my business COM objects.  I've consulted various texts and can find no information that helps me understand this area.
I'm not looking for a two page explanation, I'm a fairly sharp guy, but in six sentences or less could someone point me in the right direction?
Thanks.
0
Comment
Question by:Neil Kiser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1169745
See http://www.kinetica.com/ootips/persistent-objects.html for:
* A two-page explanation of the problems involved
* A list of commercial products that provide solutions
* Many links that can help you tailor your own solution
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 400 total points
ID: 1169746
You should still use the referential integrity mechanism in the database for a number of reasons :-

1. Are you sure that the COM code will be the only code that will ever access the database ?  For example if you do dataloads or reports on the database directly ever, or even might do, then this would be a big advantage.

2. Are you sure that the COM code will be right first time ?  If you're not (how could you be ? <g>) then adding constraints (and checking return values in your functions) will help you debug your COM code (for example if breaks a uniqueness constraint).  I would especially recommend this if you are writing the COM code in C or C++, but regardless of language this applies.

3. Are you sure that the COM code can not be "mis-used" ?  Unless you define your interfaces perfectly, could somebody in 1 year or 5 years time develop an application that used the COM functions in an unexpected order or with unexpected parameters that messed up your database ?

4. Are you sure that the COM code can never fail part way through a "logical" transaction ?  If the COM code crashes or fails half way through an operation the database code be left in a undefined state (example: orphaned records).  Using DB Transactions/Roll-back can help, but doesn't 100% prevent problems of this type, as how you use the database (or write your COM code) may not exactly fit in all cases "logical" transactions to the transactions as implemented through the database API.

Bottom line: use database integrity mechanisms for additional security, doing so will also help you debug & verify the COM code as correct.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question