473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 1181
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*************@TK2MSFTNGP12.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**************@TK2MSFTNGP11.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*************@TK2MSFTNGP15.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
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...
3
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...
4
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
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...
3
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...
1
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...
105
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...
4
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...
3
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...
0
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.