473,938 Members | 17,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Design question - Inherit or not

I have a database with two tables "Structure" and "Data". The Data table
contains the data for my application, so no problem there. The Structure
table effectively puts some organisation to the Data table. It contains a
"tree structure" of records linked by parent/child/sibling pointers plus the
key of the data record that it refers to. It is possible for the same data
record to be referred to in more than one place in the structure.

Now, when I translate this to objects, I get a Data object with the data in
it and a Structure object with the structure in it. However, in order to
render a structure object on screen, it requires some of the data from the
data object.

So, should "Structure" be derived from the Data object, or should the
Structure object contain a Data object? My initial reaction is that
Structure inherits Data, but thinking about it, the Structure object
requires very little of the Data object in order to render it, so inheriting
a full Data object seems like way too much of an overhead. I could create a
Structure object that contains some of the data from the data table, but
that feels too much like data duplication.

Anyone got any opinions (As you can tell from the description, I'm very much
a beginner at this stuff).

Thanks
Steve
Jan 18 '06 #1
7 1208
Steve,

What database are you using.

In my opinion has a good database all that what you call Structure explicit
in it.

Should you not review your design if you are not creating things which exist
already?

Cor
Jan 19 '06 #2
The database will be Access. Maybe I'm out of date, but I don't know how the
database can provide a hierarchical structure (like a tree - think of it
like your folder structure in Windows Explorer) with facilities to quickly
reorganise the structure with drag and drop.

Then again, I'm still stuck in the DAO days, maintaining an 11 year old app,
so maybe things have moved on. Can you provide me with any references as to
how to do this kind of structure in the database?

Steve
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eL******** *****@TK2MSFTNG P12.phx.gbl...
Steve,

What database are you using.

In my opinion has a good database all that what you call Structure
explicit in it.

Should you not review your design if you are not creating things which
exist already?

Cor

Jan 19 '06 #3
Steve,

You can try some samples.

Here a simple sample on our website using Northwind

http://www.vb-tips.com/default.aspx?...7-7bc3068aca2c

However there are endless have a look for master-detail samples.

I hope this helps,

Cor
Jan 19 '06 #4
Sorry, I understand the concept of master/detail records. That's not how my
data is organised though.

Think of it like the structure of a set of windows folders:

The root (C) has four folders under it called Windows, Program Files, My
Documents and Documents & Settings. Expanding My Documents reveals more
folders called My Library, My Pictures and My eBooks. So you end up with a
structure like:

C:\
Windows
Program Files
My Documents
My Library
My Pictures
My eBooks.
Documents & Settings

Each of these folders has attributes, such as the folder name, security
settings and icons etc... My "Structure" table defines the folder structures
(or relationships) and my "Data" table defines the attributes of the
individual folders.

In the structure table there are four pointers; the parent node, the
previous sibling the next sibling ad the first child node. It also contains
the key of the record that it relates to in the data table. In my structure,
you can have the same folder in more than one place, hence the reason for
splitting the structure and the data in to two tables.

In order to display the tree, I need to retrieve the structure information
from the structure table and the folder name from the data table. So my
question is;

1/ should the Structure object inherit the Data object (so including a
lot of data that I don't need)

2/ should the Structure object contain a reference to the data object
(same problem - but I have the option not to fill in the data until I need
it).

3/ should the Structure object just retrieve what data it needs from the
Data table (so introducing the possibility of data duplication).

Sorry if my earlier explanation wasn't clear. I tending towards option 3 now
I've written it out. It's not pure object oriented design, but it's
practical.

Thanks
Steve


"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uq******** ******@TK2MSFTN GP11.phx.gbl...
Steve,

You can try some samples.

Here a simple sample on our website using Northwind

http://www.vb-tips.com/default.aspx?...7-7bc3068aca2c

However there are endless have a look for master-detail samples.

I hope this helps,

Cor

Jan 19 '06 #5
Steve,

Maybe I miss something however what you tell looks for me as how the dataset
is organized.

The dataset exist from
DataTables
DataColumns which desctribes the attributes
DataRows which hold the data in items conform the describtion DataColumn
DataRelations
Describes the relations between Parents and childs tables (for the rows
of course)

http://msdn2.microsoft.com/en-us/library/dbwcse3d.aspx

However, maybe I am completely beside your problem.

Cor
Jan 19 '06 #6
Cor
Thanks for hanging in here. I think we're getting hung up on the
database organisation too much. I'm looking for guidance on the definition
of "Objects", not the table relationships. I'm VERY new to objects! Lets
simplify it a little.

I have two tables (a) and (b). In order to display the data in table (a), I
need a subset of the information that is in table (b). I already have an
Object defined that encompass the full content of table (b) and now want to
define the object that I need in order to display a record from table (a).

Should my (a) object contain an instance of object (b), should (a) inherit
(b) or should I forget that there is an object (b) and create a new object
(a) that contains just the data I want from table (b) even though this might
lead to data duplication.

Steve


"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:On******** *****@TK2MSFTNG P15.phx.gbl...
Steve,

Maybe I miss something however what you tell looks for me as how the
dataset is organized.

The dataset exist from
DataTables
DataColumns which desctribes the attributes
DataRows which hold the data in items conform the describtion
DataColumn
DataRelations
Describes the relations between Parents and childs tables (for the rows
of course)

http://msdn2.microsoft.com/en-us/library/dbwcse3d.aspx

However, maybe I am completely beside your problem.

Cor

Jan 19 '06 #7
Steve,

Why don't you accept the build in class "dataset".

It is a fully OOP class, which you need to instance to get an object.

In my opinion does your current approach leads to an own build solution,
which never sustain very long.

In the beginning of .Net we saw a lot of people trying to do with what you
are busy with (if I understand you well).

However just my idea and I can completely misunderstand you.

Cor
Jan 19 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2380
by: Soulshift | last post by:
Hi all, Here's my problem. I have a design where the class Container inherits class Widget, and is used to contain and handle the proper display of widgets and behaves like a widget itself. I have a class IsoWidget which inherits from class Widget which is used to display isometric widgets. I want to make a class IsoContainer (which contains IsoWidgets and behaves like an IsoWidget), and since an IsoContainer seems like it should...
3
3166
by: Omer van Kloeten | last post by:
The Top Level Design: The class Base is a factory class with a twist. It uses the Assembly/Type classes to extract all types that inherit from it and add them to the list of types that inherit from it. During run time, using a static method, the class creates an instance of the derived class using the Activator class and returns it. This design pattern is very similar to the design pattern applied by the Assembly class. The twist is...
4
1615
by: Merlin | last post by:
Hi Imagine the following classes (A class diagram will help) BASE, A, B, C, D, E, F, G. A, B, C, D, G inherit from BASE. E, F inherit from D.
1
2168
by: Mark | last post by:
I have .aspx code-behinds that inherit from the class below. The code runs just fine, but the form designer bombs at design time when trying to view the .aspx page in VS.NET 2003. If I comment out the single line of code below, then there is no error. I posted the error message below - it implies that this code is being run at design time, but it bombs due to the fact that it isn't run time. Is there a line of code I could add to only...
3
1504
by: Mojtaba Faridzad | last post by:
Hi, my question is about OO design. imagine we have 2 classes with some common members and some different members. which one is better and why: 1) design class A completely and B as a drived from A with the different members. 2) design a super class with common members then design class A and B drived from this super class with their different members.
1
1901
by: Josh28 | last post by:
Hi We are a group of two chaps just out of undergrad, we created a software to automate the use of Design Patterns. We have put it up at Source Forge--http://dpatoolkit.sourceforge.net/ The software has been designed using the .NET framework and coded in C#. The patterns can be stored as plug-ins in XML, adding any number of attributes like Intent, Behavior and the like... Class
105
5506
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does not work. It only works on lists and strings, for no obvious reason. Why not on all sequence types? Or, another example, the index() method has start and end parameters for lists and strings. The count() method also has start and end parameters...
4
1869
by: kikazaru | last post by:
Can I write methods in one class A, that use methods in another base class B, in such a way that I can make a class C1 that inherits A and B1 (a child of B) so that the methods in A use the implementations of B's methods provided by B1? (And also make C2 inheriting A and B2 (another child of B) and C3 etc.). Is it possible to do this entirely with inheritance, or do you have to store a pointer to a class of type B in A in order to get this...
3
1853
by: Mousam | last post by:
Hi All, First of all forgive me for the length of this post. I am developing one library for some text editor. In this library I want to provide a set of C++ classes which will enable client (of the library) to add tool bars to the text editor. The requirements are: -Client can add as many tool bars as he wants to add. -In each toolbar there will be some tools. Tools can be of button
0
1648
by: patrik.nyman | last post by:
I have a modular set of xml schemas that are being <include/>d into a master schema. The modules have no target namespace, but `inherit' the namespace of the master schema -- this is the so called Chameleon design. The master schema in its turn is <import/>ed into other schemas with different namespaces. Now, in the modules I'd like to use Schematron rules. Problem is, these do not seem to inherit the target namespace of the master...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11521
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6072
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6292
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4444
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3498
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.