I just learnt about ERDs, how to generate them and their purpose today. I tried generating to chart the structure of the database of my website using pygraphviz, pyparsing and pydot but I realised I have no idea how to read this cool-looking diagram.
Can anyone help me interpret this? Any help is very much appreciated!!
Here is the picture:
Here's one tiny part of your picture cropped so I can actually read the text in the image.
Each block with the dark box at the top is one of your database tables.
The Message table (entity) is probably the most reasonable one to talk about. All of the columns of the Message table are listed in the box.
The lines connecting boxes are the relationships between the tables. One of the lines points to the Recipient table(entity). That entity is connected by the received_messages code.
Hence, the diagram is called an entity-relationship diagram. Here's a more detailed explanation I found: What is Entity Relationship Diagram (ERD)?
Generally, you draw independent portions of your database in separate diagrams so it doesn't get so confusing.
Related
I'm not sure whether this question has already been asked in the past.
I'm writing a webcrawler, intended to extract information from multiple websites for promotions,prices and product descriptions.
Which database choice would be ideal to do an in memory comparison on the data of promotions and prices, based on identification of the same product from multiple websites.
I know the design is going to be complex for the Scraper, HTMLDataProcessor and Storage for wrangling. But, I'm looking for a solve for the data layer choice.
Appreciate the help on this.
I'd suggest first you create your object model or Entity relationship diagram for all the entities.(a.k.a ER diagram)
For instance you can see the tutorial here: http://creately.com/blog/diagrams/er-diagrams-tutorial/
Once you have the diagram and relationships between your entity then you can make a choice of whether you need relational database or not.
You need to answer question like:
Do you care about FK (foreign key) constraints?
What is the most common query and do you care about it's performance?
Is an in-memory database sufficient or do you need data to be persisted?
Think along those lines.
Good day,
Real estate companies have several Buildings, each Building managed by one or more Managers, Managers have access to one or more Buildings. So, there is a many-to-many relationship between Managers and Buildings. It has to be a table such as Permissions to get rid of many-to-many relationship.
Please help me to figure it out, what is the best design for the database ?
I came up with a two candidate diagrams, which one is better? If neither of them are good, what should I change ?
http://i.stack.imgur.com/Z0l6h.png
http://i.stack.imgur.com/Dg5Sv.png
Sincerely
The second picture seems closest
I'd suggest moving the boxes around a little to show the hierarchy. Put Companies top and center, then on the next row, Managers on the left, Buildings on the right and Permissions between those two.
ER diagrams are used for two different purposes. One purpose is to illustrate the subject matter entities, and the relationships between them, as understood by subject matter experts. This is called a conceptual model of the data.
The other purpose is to illustrate a proposed database design, one where the relationships are not only expressed, but also implemented somehow. If the design is relational (which it usually is) many-to-many relationships are expressed by creating an intermediate table. This is called a physical model of the data (in some literature it's called a logical model). This is what you have done in your second diagram.
Your first diagram could be cleaned up a little by eliminating the box named "permissions", and putting a crows-foot at both ends of the line connecting Managers and Buildings.
Now to come back to your question: which one is "better"? It depends. sometimes, a conceptual diagram is better for discussing the subject matter with the ultimate stakeholders: non-technical managers who work with the data all the time, and might be called "subject matter experts".
A physical diagram is usually better when discussing the proposed design among data architects and programmers. It explains not only how the data works in concept, but also how the database is to be built. This kind of detail is glossed over by a conceptual model.
So you may end up with two diagrams, and use the appropriate one depending on your audience.
Can someone please gimme an example of both? I am super confused between the two :(
Are they same??
I am not an expert on the subject but from what I have read it seems that a context diagram is more interested in grouping and relating data based on the context from a user's point of view. So while a client may have an address, name, phone, etc. it will not relate those to the client. Instead the context diagram will relate the address, name, and phone along with a complaint description, subject, and issue category.
The erd on the other hand is more concerned with how the data is related. So the client has a 1 to n relationship with complaints and the complaints has a 1 to 1 relationship with descriptions, subjects, and complaint categories.
An erd is probably more useful to a database designer to make sure that the database can support the relationships correctly.
A context diagram (from what I understand) would probably be more useful to a web developer or interface designer so that they can pull the correct data into certain views or forms.
I have a very large database I need to diagram. The database is SQL Server 2008 on x64. It is large in that there are hundreds of related tables, each with up to 2000 fields (some are sparse), multiple relationships between tables (often hundreds per table, in fact), multiple schemas... you get the idea.
I tried to use the Database Diagrams feature of SQL Server Management Studio, but it crashed with a Win32Exception: "Not enough storage is available to process this command..."
I tried to use Visio's reverse engineering feature on a different machine to connect in and diagram it, but that's been going for a few hours with no sign of completion.
The scripts to build this giant schema are being by a tool we built for the job. While the tool is doing its job just fine, it's tricky to visualise its output.
I'm after a tool to kick out a diagram of this database so we can do this. Any suggestions?
EDIT:
Just to emphasize, the diagram is indeed not supposed to be used for actual useful reference. It's a client relationship management device to demonstrate the complexity/scale of the system.
I worked at a place that had several hundred tables (near 1k) and no one really knew what was going on in the system, company was growing and hiring a lot. A guy was tasked with doing a diagram, and he auto-magically created a gigantic tiled poster that contained every table with lines connecting various tables (going all over the place). I'm not sure what he used, it was Unix and Oracle years ago (way before Linux and open source). There was no real rhyme or reason to the layout of the the tables in his diagram. He had successfully created a diagram of every table. The "poster" was put on a wall in a common area, and got a few looks, but no one ever really used it, it was unusable, too cluttered, too unorganized. As a result, I used MS-Word to create a single page diagram containing the 20 main tables (it went through a few iterations as I "discovered" new main tables) with lines for each foreign key and each table located in a logical manner. I showed the column name, data type, nullability, PK, and all FKs. I put my diagram up on my wall by my monitor. Eventually everyone wanted a copy of my diagram, including the person that made the "poster". When I left that job they were still giving my diagram to new hires.
I recommend that you work like an explorer, find the key tables and map them as you go, making as many specific diagrams as necessary as you discover the system. Trying to make a gigantic "poster" automatically will not work very well.
Generating an image of any kind for a database of that size simply becomes eye candy that is stuck on a wall that draw's gasps, and honestly serves no real purpose except occasional glances. Why not use a tool like Red Gate's Documentation tool that will serve an actual purpose? Please understand I'm not saying this in a mocking way, but I've been down this road before trying to diagram a huge database, and I succeeded to some degree, but never found a good outlet where it was of some use.
Since you have multiple schemas maybe a good idea is to generate diagrams per schema instead
Use graphviz. Use some SQL statements to generate the digram, then run it through dot.exe to generate a PDF or PNG.
I've used it to generate digrams of data within SQL Server tables. No reason why you can use it for tables too.
http://www.graphviz.org/
There are also java, silverlight, and AJAX utilities for navigating extra large graphs, as PDF is only for one page.
I'd avoid doing the whole thing in a single diagram. As you mentioned, the tools crash, and it's probably not possible to easily comprehend a diagram with hundreds of tables with potentially thousands of records per table. Can you generate diagrams of smaller logical areas with some overlap to other
logical areas?
Alternately, you could try using something like graphviz to parse the DDL statements and then produce a graph. It will probably churn for a while, but I remember seeing in a university poster-sized diagrams with tiny print, that were probably of the same complexity as yours. Good luck!
FWIW, assuming you do want to go ahead with this I've personally found that the visual studio 2010 database modeller does the nicest diagrams I've come across so far - Just import your database as if you were going to use it for Linq2SQL
schemaspy
provides a handy interface to generate interactive diagrams that span multiple schemas using graphviz as a backend. I've never tried it on anything this size though.
IntelliJ (specifically IDEA as just tried with this, but I believe their other IDEs offer this feature https://www.jetbrains.com/) has a built in database client facility, from here you can connect to your database and analyse individual tables, specific combination or table or all your tables by highlighting the desired tables, 'right clicking' and selecting the 'diagram' option. You can save for later reference and also print. I have just tried this on a large DB of 500+ tables and it rendered in seconds, the vector diagram serves as an alternative way to digest database structures visually and the relationships and constraints between certain tables but not recommended for printing.
I'm trying to be a good developer and create some documentation before I start programming my next project.
I have created a database schema diagram in Visio and created relationships between columns.
However, I am looking for a way to make the relationships between columns more clear. I want the arrow to connect column to column.
Is there a way to do this in Visio?
You can use the Visio Drawing tools to force the Relationship Connector to glue to particular Connection Points on the Table Shapes:
Turn on Connection Points in the View menu.
On the standard toolbar find the Connector Tool just to the right of the Pointer Tool. Click on the little arrow and change to the Connection Point Tool.
Hold Ctrl and click on one of the Table Shapes at the point where you want to join the Relationship Connector.
Do the same on the other Table Shape.
Glue the ends of the Relationship Connector to the Connection Points you just added.
You will have broken the relationship. To fix it, select the Relationship Connector and view the definition of the relationship in the Database Properties Window.
Associate the fields again.
(This was tested with Visio Enterprise 2003.)
If you click on the relationship arrows, green midpoints will appear. You can use these to drag the relationship arrow up and down. Be careful not to move the endpoints, though, because Visio will disassociate that connector from the table object.
To my knowledge this is how visio draws it, and it is not possible to get it to point at an exact column. its kinda annoying, but I guess you learn to live with the FK markings
The answer is that it won't, but you can click and drag the lines around. The method I use to get around this is to name the FK relationships and display the names (there is an option to do this in Database->Options) or to label the relationships with the column.