Automating reverse engineer database model with Visio - database

We develop and maintain our database schema with a custom tool. SQL scripts and runtime files are generated from that tool. However, it does not provide a very good visual representation.
Lately I been using Visio to reverse engineer the schema. This is working great so far. But to be able to do this, I need to:
create an empty database
execute the generated script
start up visio
choose reverse engineering and choose the created database
select all tables, etc
wait for generation
I really want to automate this process. Step 1 and 2 are easy, but how can I automate the other steps.
I've been looking for a C# library to create Visio diagrams, but they al seem not suitable for this task.
For instance
http://visioautomation.codeplex.com/ and http://www.graphviz.org/ look promising, but on a closer look they were not appropriate.
I've tried to record macro, but the macro recorder does not work in conjuction with the reverse engineering tools.

Michiel,
I am using Visio 2007 and SQLite 3.
Tonight I had a crack at reverse engineering my Sqlite3 database with success. The key is to download an ODBC driver for Sqlite. I found some here > http://www.ch-werner.de/sqliteodbc/. I installed the current one at the top of the list "sqliteodbc.exe".
Then the MSVisio set up was a bit muddled so forgive me if I do not explain the details in an exact, repeatable format.
The new installed ODBC driver should appear in Visio when you select: Database > Reverse Engineer > Setup.
Scroll down and check one of the three Sqlite drivers - I chose the "SQLite3 ODBC Driver"
Then click on "New" > Check "System Data Source" > Scroll down select "SQLite3 ODBC Driver" > Click "Finish"
On the dialog that it entitled "ODBC DNS Configuration" is where you enter your Sqlite database settings. The "Database Name" is simply the path and file name of your database.
The "Data Source Name" can be anything meaningful to you as it will appear in the Visio dropdown whenever you want to reverse engineer. There are some other settings you can experiment with as well.
When you commence reverse engineering you will be asked to connect to your datasource using your credentials. At this point you will get a warning ...
Warning! You are using a Visio
'ODBC Generic Driver' to connect
with a 'SQLite' DBMS datasource. By using
an incompatible driver, it is possible
that the catalog information retrieved
will be incomplete.
Just click 'OK' and ignore this.
Unfortunately, in the next screen the option to select "Views" and "Triggers" are greyed out (you can select Tables: Primary Keys, Indexes, Foreign Keys though). This is a shame as I have defined a lot of these in my schema and I have benefited from rev-enging these in Oracle many times in the past.
That is it. Hope someone can find a fix for rev-enging the views.
Dan

Have you tried using the "Refresh" feature? I'm not sure if that is a 2010 thing or if it was always there. You point it at the database and it updates your model with the changes since last time.

Related

Using SSDT to do reverse engineering so I can get overview of schema just like in MySQL

I just installed and imported my database in Visual Studio , All I want to see is schema to get a quick relation of among different tables , I was hoping if I could get a way to do the same in SQL server just like it can be done with my sql reverse engineering
I use Azure data studio (the extension is buggy ), I also have Sql server manangement studio , I also visual studio and selected database management pack where SSDT was included and now I simply imported the database which I want schema for
SSMS has some rudimentary diagram tools to pull in objects and see any relations that exist. Something to watch for is that if you add any relations or modify anything other than the layout on that diagram, you actually change the database itself.
There are some free/cheap ERD apps/sites that you may want to investigate and many will give you a script to run in SQL Server to extract the schema in a format they can use.
I'd recommend searching on ERD apps that can do database diagrams, but for a free option you may want to check out https://dbschema.com/ (there's a free/trial version) or https://dbdiagram.io as they can handle some simple ER diagrams. (note - no affiliation to either, just some examples/options)
You can't easily forward-engineer changes with it, but it can work to just see the relationships visually. If you're going to use ER diagrams regularly, a paid option will be much more helpful. There are a lot of options available, but for that sort of design work you probably want collaboration and the ability to push out changes to a live database from the ERD.

How to connect the Data Modeler with SQL Server 2008?

I want to document a SQL Server 2008 database. I have been asked for the Diagram and the specifications of the tables, fields, data type, etc. (Data Dictionary).
The problem is that I can not find a program that suits my requirements. The Erwin Data Modeler has a reverse engineering tool, but it is not useful because it does not allow me to specify only the tables that I want to diagram, at the very same request the schemas (But it is in this program that I am asked to do the diagramming) . SQL Server Management Studio is not an option because it is the same that manages the Databases (it implies modifying the DB in some way) and it is not very flexible with the choice of tables.
So I resorted to Data Modeler works perfectly with an Oracle database, you can make diagrams, generate scripts (the latter helped me to pass diagrams to Erwin), and even generate documentation of objects, etc. But I have not been able to connect it to SQL Server 2008 to do the same thing I did with Oracle. I downloaded the jtds-1.2.jar to make the connection but I do not know exactly how to do it.
In summary I need a program that allows me to choose the tables to which I want to diagram (These are things that are achieved with the Data Modeler) and then be able to open them in the Erwin (With the script that generates the latter) which is the target program. And also the field documentation, although this is a secondary issue to the question.
It would be helpful if you know of any other method, program or procedure.
download from sourceforge jTDS v1.3 or 1.3.1
get the JAR out of the zip
add it to your sqldev folder
open preferences in the tool, and go to third party drivers, under database page i think, and then when you get to connection dialog, there will be a SQL Server and Sybase connection type
i talk about this in more detail here
You can connect to a SQL 2008 db and RE the databases into one or more data models, and then generate data dictionary reports and DDL scripts. And a lot more..get v4.2 if you want to generate HTML reports that include the diagrams themselves.

Write Access Client App for SQL Server 2005 Backend

I'm writing an inventory/payroll system, and I'm storing all the records on a remote server running SQL Server 2005 on Windows Server 2008 R2. I was wondering how I could start writing forms(very basic) in MS-ACCESS 2010 to upload things to the database. I just want to test it out to make sure that once I implement the entire database, things will work smoothly and without error. I want to figure out how to just make a single form that will be connected to the database, right now the form will just be a simple single text input with a submit button, that will be uploading barcodes(strings not images).
If I need to clarify anything, please just ask.
Thanks in advance for any help
Microsoft has tons of useful "Getting Started" articles.
This one explains how to connect to SQL Server: http://office.microsoft.com/en-us/access-help/import-or-link-access-to-sql-server-data-HA010341762.aspx
This one covers all sorts of forms: http://office.microsoft.com/en-us/access-help/CH010369205.aspx
Go there, you will find a lot that can help you with whatever you are going to do.
Make sure you have the SQL Client driver installed on the workstation where you'll be using MS Access. You can download it here (look for sqlcnli).
The simplest way to get started is to build an ODBC DSN. Access can then link to your SQL Server tables using that DSN. How to Create a DSN
In Access, Go to the "External Data" option and choose ODBC. Locate your DSN and then select which tables you want Access to be linked to.
After your linked tables are showing up in the tables list, click on one of the tables, go to the Create tab (2007, not sure about 2010) and choose Form. This should automatically create a form for you using the table you had selected when you clicked the Form button. There's no need to write code or add buttons to this form. The default form can do all CRUD operations as long as permissions for all CRUD have been granted to the username you used when you created your DSN.
Some developers prefer to use ADO (code only, no linked tables or form wizards) or Pass Through Queries to access SQL Server from Access. I can't really tell you what you should be using because it depends on so many different factors including (but not limited to) size of project, amount of records, skill level, personal preferences, etc.

Generate the ERD for an existing database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I have a PostgreSQL database. I want to generate ERD from that database. Are there any built-in tools to do it or maybe some third-party tools?
You can use dbeaver to do this. It allows you to export the ER diagram as png/svg etc.
DBeaver - https://dbeaver.io/
Double click on a schema (eg, Schemas->public->Tables) and open the "ER Diagram" tab (next to "Properties" tab)
pgAdmin 4 version 30 and newer can generate the ERD from an existing database. Just right-click on the database and select Generate ERD.
We used DBVisualizer for that.
Description:
The references graph is a great feature as it automatically renders all primary/foreign key mappings (also called referential integrity constraints) in a graph style. The table nodes and relations are layed out automatically, with a number of layout modes available. The resulting graph is unique as it displays all information in an optimal and readable layout.
from its site
pgModeler can generate nice ER diagram from PostgreSQL databases.
https://pgmodeler.io/
License: GPLv3
It seems there is no manual, but it is easy enough without manual. It's
QT application. AFAIK, Fedora and Ubuntu has package. (pgmodeler)
In the latest version of pgModeler (0.9.1) the trial version allows you to create ERD (the design button is not disabled). To do so:
Click Design button to first create an empty 'design model'
Then click on Import and connect to the server and database you want (unless you already set that up in Manage, in which case all your databases will be available to select in step 3)
Import all objects (it will warn that you are importing to the current model, which is fine since it is empty).
Now switch back to the Design tab to see your ERD.
Download DbVisualizer from : https://www.dbvis.com/download/10.0
and after installing create database connection:
Change highlighted detail of your db and test by click ping server. Finally click connect
Enjoy.
I wrote this utility, it automatically generates the DSL code from a postgres database which you can then paste into dbdiagram.io/d website to get ER diagrams
https://github.com/nsingla/dbdiagrams
Our team use Visual Paradigm to generate ER diagram from database in many of our projects. While we mainly work on MS SQL and Oracle, as I know they also support some other DBMS like PostgreSQL, MySQL, Sybase, DB2 and SQLite.
Steps:
Select Tools > DB > Reverse Database... from the toolbar of Visual
Paradigm
Keep the settings as is and click Next Select PostgreSQL as
driver and provide the driver file there. You can simply click on
the download link there to get the driver.
Enter the hostname, database name, user and password, and then click Next
They will then study your database and lists out the tables in it.
Select the table to form an ERD and continue, and that's it. An ERD will be generated with the tables you selected presented.
BTW they also support generating and updating database schema from ERD.
Hope this helps. :-)
More information about generating ERD from PostgreSQL database
ERBuilder can generate ER diagram from PostgreSQL databases (reverse engineer feature).
Below step to follow to generate an ER diagram:
• Click on Menu -> File -> reverse engineer
• Click on new connection
• Fill in PostgresSQL connection information
• Click on OK
• Click on next
• Select objects (tables, triggers, sequences…..) that you want to reverse engineer.
• Click on next.
If you are using trial version, your ERD will be displayed
automatically.
If your are using the free edition you need to drag
and drop the tables from the treeview placed in the left side of application
Another option is use Oracle SQL Developer. Two steps as below:
(1) First of all, you need to connect SQL Developer to your PostgreSQL database.
(2) Then you can generate an entity-relationship (ER) diagram using SQL Developer
Perhaps have a look at AquaFold's Aqua Data Studio. It is a database IDE with entity-relationship diagramming. It also includes data profiling. It is not free but its price is very reasonable considering its capabilities.
I use DrawERD for ERD & DB doc. https://drawerd.com
postgresql_autodoc is a cli for doing this. Doesnt do cardinality, but none of the above mentioned GUI tools do as well.
You can generate ER diagram from PgAdmin.
Open PgAdmin
Right click on any table and select statement and it will show two window one is query other is graphical window so you can add the table which you want to generate the diagram.
To save go to save as and select Graphical Query (image)
Open MySQL Workbench. In the home screen click 'Create EER Model From Existing Database'. We are doing this for the case that we have already made the data base and now we want to make an ER diagram of that database.
Then you will see the 'Reverse Engineer Database' dialouge. Here if you are asked for the password, provided the admin password. Do not get confused here with the windows password. Here you need to provide the MySQL admin password. Then click on Next.
In the next dialouge box, you'll see that the connection to DBMS is started and schema is revrieved from Database. Go next.
Now Select the Schema you created earlier. It is the table you want to create the ER diagram of.
Click Next and go to Select Objects menu. Here you can click on 'Show Filter' to use the selected Table Objects in the diagram. You can both add and remove tables here.Then click on Execute.
6.When you go Next and Finish, the required ER diagram is on the screen.

Database Versioning Using Visual Studio

In the SO podcast episode 54 Jeff talked about using Visual Studio to save all the database objects to individual files. This sounded like just what my team needed to better implement database schema changes into TFS and I told my lead about it. He thinks it's a great idea to.
Unfortunately, so far I've had no luck getting this to work for me. One of my problems is that I don't have SQL Server installed on my local box (dept policy). I'm obviously doing something wrong.
Can someone give me a rundown of the steps or provide a decent link?
Thanks!
1) Create a connection to the database in Server Explorer.
2) Right-click on the connection and select Publish to provider...
3) Next, Script to file, Next, Types of data to publish should be Schema (unless you need some initial data), finish.
4) Add script to the project and check into source control.
He was referring to a project type in VS that supports managing databases, including (if you set it up correctly), versioning your database publishes.
Check out this article on Database Projects in VS
You want to use the GDR 2. (Sometimes called Data Dude)
This allows for a completely offline solution. You don't need to have SQL Server installed on your machine for this to work. (In fact the GDR is the first version that does not care if you have SQL Server installed.)
I use the GDR for my db (a team of 3 devs and 2 testers) and it works GREAT!
Here is a link for the GDR 2 release:
http://blogs.msdn.com/vstsdb/archive/2009/04/21/microsoft-visual-studio-team-system-2008-database-edition-gdr-r2.aspx
And this is a link to the actual bits:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed
The basic use is to import from an existing DB and server. (You will probably want a server project and 1 or more DB Projects)
You can then make your changes off line. When you are ready to send you changes back to the DB you can delploy (make sure you set up your deploy options first as I think the default is to drop the db and re-deploy). You can also do a Data->Schema Compare in Visual Studio and comapre your project to your database then get a script of changes from the diff output.
It takes a bit of work, but it really allows great source control and is easy once you get the hang of it. (I have my db auto deploy in my night time build twice a week.)
If you're importing an existing database schema, its important to get the right database project. You should likely be using "Database Projects\SQL Server 2005 Wizard".
Visual Studio requires a database connection it can use to create temporary copies of the databases it is working with. It sounds like this is the issue. Do you have SQLExpress on your local box? Use that as the deployment target (server name would be .\sqlexpress if . does not work).
As an alternative, grab update GDR 2 for Visual Studio. Allegedly, it allows one to work with database projects without using a local instance of sql server to deploy temporary working copies of the database.

Resources