Sajad Bahmani
Sajad Bahmani

Reputation: 17469

Tool for convert SQL code to diagram

can any one say some way to convert SQL code to data diagram like ERD ? for som DBMS like MySQL or general SQL

Upvotes: 12

Views: 49046

Answers (5)

Mamtha
Mamtha

Reputation: 1

-- User Table CREATE TABLE User ( user_id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, email VARCHAR(100) UNIQUE NOT NULL, password VARCHAR(100) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

-- Meal Table CREATE TABLE Meal ( meal_id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, meal_name VARCHAR(50) NOT NULL, meal_date DATE NOT NULL, FOREIGN KEY (user_id) REFERENCES User(user_id) ON DELETE CASCADE );

-- FoodItem Table CREATE TABLE FoodItem ( food_item_id INT AUTO_INCREMENT PRIMARY KEY, food_name VARCHAR(50) NOT NULL, calories_per_100g DECIMAL(5,2), protein_per_100g DECIMAL(5,2), carbs_per_100g DECIMAL(5,2), fats_per_100g DECIMAL(5,2) );

-- Nutrient Table (stores details of food items in each meal) CREATE TABLE Nutrient ( nutrient_id INT AUTO_INCREMENT PRIMARY KEY, meal_id INT, food_item_id INT, quantity_in_grams DECIMAL(5,2) NOT NULL, -- quantity of food item in the meal FOREIGN KEY (meal_id) REFERENCES Meal(meal_id) ON DELETE CASCADE, FOREIGN KEY (food_item_id) REFERENCES FoodItem(food_item_id) ON DELETE CASCADE );

Upvotes: 0

Ahmed M. Matar
Ahmed M. Matar

Reputation: 522

using mysql Workbench do the following:

1- file -> new model

2- file -> import -> reverse engineer mysql create script

select ur mysql file script

and tick on place imported objects on a diagram

and press next and finish

Upvotes: 16

sstauross
sstauross

Reputation: 2680

Use MySQL WorkBench. It's perfect and absolutely compatible with MySQL, Oracle powered!

Check it out here: MySQL Workbench

Upvotes: 5

Sajad Bahmani
Sajad Bahmani

Reputation: 17469

For MySQL can use sqlyog :

SQLyog MySQL GUI is the most powerful MySQL manager and admin tool, combining the features of MySQL Query Browser, Administrator, phpMyAdmin and other MySQL Front Ends and MySQL GUI tools in a single intuitive interface.

http://www.webyog.com/en/

Upvotes: 2

Dwight T
Dwight T

Reputation: 1487

ModelRight, http://www.modelright.com/ , is a good ERD application and is free for MySQL and ODBC connected databases. It reverse engineers from a DB, if you want to reverse engineer from SQL Script, you should check out Dezign for Databases, http://www.datanamic.com/

Upvotes: 2

Related Questions