How to build a DataBase of data types (int, char, struct, …)?

M

Morize

How to build a DataBase of data types (int, char, struct, …)

I would like to build an ACCESS DataBase, containing information about all the data types we use.

For example

Suppose, we have the following C/C++ code

typedef char ARRAY_8_BYTES[8]

struct Foo

int a[20]
int b
ARRAY_8_BYTES a6
char a[8]
}

struct Foo

Foo1 foo1
Foo1 *pFoo1
char c[12]
}

Ideally, I’d like to have an ACCESS DataBase, containing data about the Foo1, Foo2 structures. So, I would be able to build a program, which uses this data base and (for instance) generates automatically the C code structure definitions above

The questions I ask myself are

1) How to organize data which is hierarchical by nature using a relational
data base such as ACCESS
2) Are they better solutions than using ACCESS to solve this kind o
problem?
3) Do you know about other databases or commercial softwares that permit to
do this
4) Could you please give me either a precise answer or links which can help
me

Many, many Thanks
 
T

Tim Ferguson

struct Foo1
{
int a[20];
int b;
ARRAY_8_BYTES a6;
char a[8];
};


CREATE TABLE FooOnes (
Bee INTEGER NOT NULL
CONSTRAINT pk PRIMARY KEY,
Array8Bytes VARCHAR(8) NULL,
Aye VARCHAR(8) NULL
);

CREATE TABLE FooOneAValues (
Bee INTEGER NOT NULL
CONSTRAINT fkBee FOREIGN KEY REFERENCES FooOnes,
Index INTEGER NOT NULL
CONSTRAINT UpperBound Index < 20,
AValue INTEGER NULL

CONSTRAINT pk PRIMARY KEY (Bee, Index),
);


Note that we implement arrays like int a[20] in a separate table.
struct Foo2
{
Foo1 foo1;
Foo1 *pFoo1;
char c[12];
};

See above. Since the whole point of database design is to abstract right
away from any machine considerations, then the Foo1 pointer would probably
be a foreign key referencing the FooOnes table. You would also probably not
want to duplicate a whole FooOnes record within a FooTwos record, so
presumably that would be a FK too.

But then again, since the whole point of R is getting the semantics
correct, and the whole point of c is the direct manipulation of machine
reources, the comparison is pretty meaningless.
1) How to organize data which is hierarchical by nature using a
relational
data base such as ACCESS?

You don't need to ask yourself: there are simply forests of books called
"Relational theory for Dummies" that answer exactly your question.
2) Are they better solutions than using ACCESS to solve this kind of
problem?

You have not posed a problem. You have printed a meaningless bit of
computer jargon from a procedural language and asked whether the same
result could have been achieved using a declarative one. The answer is yes.
There is no problem.
3) Do you know about other databases or commercial softwares that
permit to
do this?

Any R or near-R database management system... Come to think of it, even a
line or two of VBA6 or higher could have done it too.

4) Could you please give me either a precise answer or links which can
help me?

You will have to give a precise question in order to get a precise answer.

HTH


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top