Generating Jet DDL

D

David W. Fenton

I'm embarking on a collaborative project to create some generalized
database templates and one of the tasks is to write DDL to generate
the schema. It would be nice to have DDL that works for all
databases, and I've been using MySQL to prototype and phpMyAdmin (a
web-based admin front end to MySQL) to generate database-specific
DDL. But none of the resulting DDL works in Jet without major
adaptations.

Is there any way to generate DDL that will work in Jet without a lot
of futzing around with manual editing of the SQL?

It seems like it might be fairly simple to write a routine that
would replace certain standard commands/data types with the
Jet-specific versions, but it obviously couldn't do all of it. But
that might be better than redoing the whole thing by hand.

Any suggestions?
 
D

david

No, we do it by hand.

But after a couple of tries, we noticed that if we knew what we
were doing there was less translation.

For example, if you have a 32 bit number, you don't have to
translate INTEGER to LONG.

If you want a portable database design, you won't be using
BOOLEANS or BITS at all.

And changes that you can implement in MySQL as a single DDL
statement, you may choose to do as multiple statements, just so
that they translate more easily.

Also, you may want to use an ADO connection rather than a
DAO connection: there may still be things which are still only
available when you use the ADO connection (?DEFAULT?)

(david)
 
D

Danny Lesandrini

Yeah, I sort of noticed that after I posted the link for dbScript. It builds scripts
to recreate an Access MDB set of tables.

If and when I had to create SQL Server scripts, I'd follow Albert's suggestion.
 
D

David W. Fenton

Some of us simply up-size the access database to sql server, and
then use sql server to generate the scripts for us. Quite sure you
can even use the free edtiion of sql server to do this..

To generate DDL for Jet?
And, then been "several" examples of code posted in ms-access that
generates DDL for the tables..

Here is one such:

http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=289

That's interesting, but it doesn't get me from a MySQL table to a
Jet table. It only gets me DDL for an existing Jet table. That's
certainly useful once I have the tables in Jet, but it's not so
useful if I'd like to maintain the schema in one place and generate
DDL for different target databases from a single source database.

With multiple database templates, this gets more complicated.
 
D

David W. Fenton

David, someone once sent me a link to a product that claims to do
scripts. It's called dbScript and I did play with it, but not
seriously. Might be worth a look.

http://dbweigher.com/dbwscript.php

The problem is that this is backward for my current problem -- I
need to be able to generate Jet DDL without having the Jet database
already created.

Indeed, if the project comes to fruition, I'd likely not post Jet
DDL at all, just an MDB with empty tables. But I'd still need to
manage that MDB template as part of a larger project of generating
the same schema for many different db engines. Right now, MySQL and
phpMyAdmin is the most versatile tool I have (it can generate
several dialects of DDL), but Jet DDL is way too foreign for any of
its results to work without significant rewrites.
 
D

Danny Lesandrini

David:

Sorry about that. I misread the issue. Don't have any leads on
converting MySQL scripts to Jet.

What if you imported the MySQL tables and then scripted them?
It would give you a script that may be used for future builds.
 
A

Albert D. Kallal

David W. Fenton said:
With multiple database templates, this gets more complicated.

Agreed. There is a "number" of db tools such as erWin that are able to
generate sql scripts for different target databases, but then that means you
have to maintain/use/design your table stuff in erWin and not use the native
database tools.

I seem to recall turning on the "ansi sql" options in ms-access helped the
consumption of general ddl commands for jet......

I don't think there really an ideal solution here because it kind of means
either:

a) use some schema design tool like erWin, or office Viso
b) stick to 100% ansi sql, but then some databases don't have particular
features
(eg: some systems need triggers to enable cascade updates for example --
feature sets between databases are not common. When I started playing with
MySql the Referential integrity was a "add-on" by the inno DB extensions.
So, even the standards of setting up RI are not always consistent and
compatible between systems

c) Build a translator of some type. this is hard to do. Likely better to
have some type of "meta" data that defines the structures such as a
diagramming tool, and then that tool is able to general ddl for the given
platform with the differences taken into account.

No question that we tend to lack decent scripting tools for JET databases
and Rogers code is start. The upzise to sql server is another way to get
scripts, but these approahces certainly do not deal with the differences in
feature sets that database engines have....
 
A

asma salah

i'm newuser
david said:
No, we do it by hand.

But after a couple of tries, we noticed that if we knew what we
were doing there was less translation.

For example, if you have a 32 bit number, you don't have to
translate INTEGER to LONG.

If you want a portable database design, you won't be using
BOOLEANS or BITS at all.

And changes that you can implement in MySQL as a single DDL
statement, you may choose to do as multiple statements, just so
that they translate more easily.

Also, you may want to use an ADO connection rather than a
DAO connection: there may still be things which are still only
available when you use the ADO connection (?DEFAULT?)

(david)
 
P

Paul Shapiro

ERWin, ER/Studio and probably other data modeling tools can do this kind of
thing. The tools are expensive though- typically a few thousand dollars.
Both tools can be used to synchronize changes made in either the model or
the db. Very nice tools, and well worth owning one if you do much db design.
The last I knew both ERWin and ER/Studio actually write code to create an
mdb using DAO. Neither one used sql for generating Access databases. One
advantage of using DAO is you can specify some of the access-specific table
and field properties, like Description.
 
D

David W. Fenton

Agreed. There is a "number" of db tools such as erWin that are
able to generate sql scripts for different target databases, but
then that means you have to maintain/use/design your table stuff
in erWin and not use the native database tools.

Well, to be fair, I'm using phpMyAdmin to model the schema and
generate several varieties of DDL, so it would just be switching
from that to something else (though the alternatives you mention all
cost $$$).
I seem to recall turning on the "ansi sql" options in ms-access
helped the consumption of general ddl commands for jet......

Hmm. I'll have to try that and see what happens.
I don't think there really an ideal solution here because it kind
of means either:

a) use some schema design tool like erWin, or office Viso

I'm already using a variety of this, i.e., phpMyAdmin.
b) stick to 100% ansi sql, but then some databases don't have
particular features
(eg: some systems need triggers to enable cascade updates for
example --
feature sets between databases are not common. When I started
playing with MySql the Referential integrity was a "add-on" by the
inno DB extensions.

No, that's not correct. If you use InnoDB table format, you get RI.
If you use the default MyISAM, you don't. The downside of using
InnoDB is no full-text indexing, which is very easy with MyISAM.
So, even the standards of setting up RI are not always consistent
and compatible between systems

Well, I've always called MySQL a toy database, though it's catching
up these days (version 5 even has triggers!).
c) Build a translator of some type. this is hard to do. Likely
better to have some type of "meta" data that defines the
structures such as a diagramming tool, and then that tool is able
to general ddl for the given platform with the differences taken
into account.

I'm trying to keep the schemas simple. I've concluded that any db
engine that implements CASCADE with triggers that aren't defined in
DDL with standard keywords in the CONSTRAINT definition will just
have to be defined as CASCADE RESTRICT (which is the default if you
don't specify any CASCADE statement). On the other hand, since
simple application templates will be developed to work with these,
the db-specific DDL to define those triggers is not going to be too
hard to write and include somewhere in the project.

But the idea at this point is to be as generic as possible without
sacrificing data integrity.
No question that we tend to lack decent scripting tools for JET
databases and Rogers code is start. The upzise to sql server is
another way to get scripts, but these approahces certainly do not
deal with the differences in feature sets that database engines
have....

Roger's code works backwards for me, as I have to have built the Jet
database before I can use it, whereas what I have is non-Jet DDL
that I want to use to create the Jet database.

Given that the plan is to support FileMaker, too, which has zero
support for executing SQL with its native data format (and thus no
DDL at all), I guess it won't be such a big deal to maintain an
Access MDB with the table structures, instead of distributing DDL
(as with the other databases). Theoretically, it's only the first
build of the database that is going to be difficult. Much of that
can actually be done quite easily in Access by opening a linked
table in design view and copying the structure and pasting it into
an Access table, and then altering the field types appropriately.
Revisions to the schema are not going to be as extensive as the
original schema, so that shouldn't be too hard.

So I don't think it's worth writing a DDL translator. At least, not
for my project.
 
D

David W. Fenton

Sorry about that. I misread the issue. Don't have any leads on
converting MySQL scripts to Jet.

I assume that by "scripts" you mean DDL? MySQL has no high-level SQL
language (like T-SQL). I was hoping that the phpMyAdmin ANSI DDL
would work with Jet, but when I tried it, it didn't. But I didn't
think to change to SQL92 mode, which might have worked.
What if you imported the MySQL tables and then scripted them?
It would give you a script that may be used for future builds.

How can I import them? Once I had the tables in Jet, I don't really
need any further "scripting," as for the project, we'll just
distribute the empty table structure as a complete MDB. The only
problem for me is the initial step of getting the tables into Jet
format.
 
D

Danny J. Lesandrini

I guess I'm not understanding the problem. The tables are in MySQL and
you only need to get them down to Access once?

I thought it was a matter of being able to build the database for distribution
on demand and I guess I was further assuming that one could simply import
tables from MySql. Is that not the case?

If you can't simply import them, can you link them? And if you can link them,
then won't one or another of these scripting tools work against the linked tables?

The answers to those questions may all be negative, but I guess that's what I'd
try.
 
D

David W. Fenton

I guess I'm not understanding the problem. The tables are in
MySQL and you only need to get them down to Access once?

Well, I'm just prototyping in MySQL because phpMyAdmin can output 3
distinct SQL dialects. That may or may not be a permanent aspect of
the project.
I thought it was a matter of being able to build the database for
distribution on demand and I guess I was further assuming that one
could simply import tables from MySql. Is that not the case?

How does one import tables from MySQL? Does TransferDatabase do
that?
If you can't simply import them, can you link them? And if you
can link them,

Well, *I* can link them, but in the ultimate project, the database
schema is going to be maintained seperately from any particular
front end. And will need to be regenerated each time there's an
update to the schema.

I'm not so concerned about the updates, myself, as my thought is
that for Access/Jet, most users won't need DDL, but will want an
empty MDB with the table structure.

On the other hand, users of the schema may later want to update an
existing database to reflect alterations, so DDL may be useful for
them.

In fact, just rambling on here on the subject has made me realize
that it will probably be a good idea to maintain both final DDL for
the whole schema for each version, as well as "delta" DDL that can
be run against a particular schema version to update it to a later
version.

Food for thought...
then won't one or another of these scripting tools work against
the linked tables?

Roger's tool works only with actual tables, not with linked tables.
I don't know about the tools that cost $$$.
The answers to those questions may all be negative, but I guess
that's what I'd try.

A correct answer is what I'm looking for. If it's negative, it's not
your fault!
 

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