Large Joins in Large Databases -- How to find Keys?

  • Thread starter WWGD
  • Start date
In summary: Hi Buzz, thanks for your reply. The thing is we are going in circles here. The dialog box in my post contains some of the tables in the database, but not all. What I am trying to do is to import the remaining tables into this list so I can create a full diagram of the database. Once I have the diagram I can find the keys, but the dialog box is not including all the tables. How do I import the ones that are missing?
  • #1
WWGD
Science Advisor
Gold Member
7,033
10,632
Hi,
I am playing around with the large(ish) database Adventureworks2014. A couple of issues , please:

1) How do we go about finding the keys when joining , say, 5 tables at a time? Does one do a database diagram using those tables?

2) I am having trying to set up the diagrams for these joins. Problem is I am having trouble finding the tables I need when designing the diagrams; tables are not listed in the dialog box used to choose for the diagram to make ( please see dialog box in center) . How do I load missing tables into the list, so I can use them for diagrams? I guess this is more of an OLAP issue than an OLTP Thanks.:

upload_2018-4-22_17-37-35.png
 

Attachments

  • upload_2018-4-22_17-37-35.png
    upload_2018-4-22_17-37-35.png
    56.3 KB · Views: 515
Last edited:
Technology news on Phys.org
  • #2
WWGD said:
database Adventureworks2014
WWGD said:
How do we go about finding the keys when joining , say, 5 tables at a time? Does one do a database diagram using those tables?
Hi WWGD:

My database experience is a bit rusty since I am retired. I would like to help you, but I do not fully understand the nature of your problem.

1. I do not know this data base. Can you link to a diagram and/or a description of its tables?
2. Can you write an example of a 5 join query to illustrate what your problem is like?
3. I always found it very helpful to have a diagram of all of, or at least that part of a database I was to prepare queries about. So, if you provide an example of a query, it would be helpful to see a diagram showing the 1-to-many relationships among the relevant tables, as well as the keys that support these relationships.

Regards,
Buzz
 
  • Like
Likes WWGD
  • #3
Yeah, I'm confused my what's being asked. Are you asking how to know which keys to compare in what order when doing large JOINs, or are you asking for help with a particular tool? Do you have access to any kind of terminal? Most database people aren't terribly familiar with GUIs. Showing you tables should be as easy as typing "SHOW TABLES;" then showing your keys is "DESC <table>;"

5 tables isn't a terribly bad join. It'll definitely require some temp table space though, so optimizing it would be beneficial. Then again, I don't know if your database has 50 million rows or 50 billion.
 
  • #4
WWGD said:
How do we go about finding the keys when joining

Are you asking how to find the database shema? Do you know what schema means in this context?
 
  • #5
anorlunda said:
Are you asking how to find the database shema? Do you know what schema means in this context?
Yes, I believe. A Schema is a container for data objects related to a given role , right?. But , don't we sometimes join tables within different schemas? I am just curious as to how one would go about figuring out the keys to use. And, just the technical point of how to import all needed tables into the to be able to create a full diagram.
 
  • #6
Buzz Bloom said:
Hi WWGD:

My database experience is a bit rusty since I am retired. I would like to help you, but I do not fully understand the nature of your problem.

1. I do not know this data base. Can you link to a diagram and/or a description of its tables?
2. Can you write an example of a 5 join query to illustrate what your problem is like?
3. I always found it very helpful to have a diagram of all of, or at least that part of a database I was to prepare queries about. So, if you provide an example of a query, it would be helpful to see a diagram showing the 1-to-many relationships among the relevant tables, as well as the keys that support these relationships.

Regards,
Buzz
Hi Buzz, thanks for your reply. The thing is we are going in circles here. The dialog box in my post contains some of the tables in the database, but not all. What I am trying to do is to import the remaining tables into this list so I can create a full diagram of the database. Once I have the diagram I can find the keys, but the dialog box is not including all the tables. How do I import the ones that are missing?
 
  • #7
newjerseyrunner said:
Yeah, I'm confused my what's being asked. Are you asking how to know which keys to compare in what order when doing large JOINs, or are you asking for help with a particular tool? Do you have access to any kind of terminal? Most database people aren't terribly familiar with GUIs. Showing you tables should be as easy as typing "SHOW TABLES;" then showing your keys is "DESC <table>;"

5 tables isn't a terribly bad join. It'll definitely require some temp table space though, so optimizing it would be beneficial. Then again, I don't know if your database has 50 million rows or 50 billion.

OK, sorry for the confusion. Let me slow myself down to make myself more clear
1) I am trying to create a full diagram of my database ( AdventureWorks2014, BTW ), meaning a diagram that contains all the tables in the database.
2) I then use the ' New Database Diagram' feature to create said diagram
3) In the process of working on 2), a dialog box containing _some of the tables_ is displayed. I can add any of the tables listed in the dialog box to create a diagram
BUT
4) The list of tables in the dialog box is not exhaustive: it does not contain all the tables belonging to AdventureWorks2014. Some of the tables in AdventureWorks2014 are missing from the list.
5) I would like to have _all_ the tables in AdventureWorks2014 listed in the dialog box, so I can add them to the diagram. How can I import the missing tables into the list in the dialog box displayed? This last is what I want to do.
Hope I made myself more understandable.
 
  • #8
WWGD said:
Yes, I believe. A Schema is a container for data objects related to a given role , right?. But , don't we sometimes join tables within different schemas? I am just curious as to how one would go about figuring out the keys to use. And, just the technical point of how to import all needed tables into the to be able to create a full diagram.

No, see below:
https://en.wikipedia.org/wiki/Database_schema said:
The term "schema" refers to the organization of data as a blueprint of how the database is constructed (divided into database tables in the case of relational databases).

It seems that your question is how to find out the schema for your database; correct?

I found this https://www.sqldatadictionary.com/AdventureWorks2014.pdf
 
  • Like
Likes WWGD
  • #10
anorlunda said:
No, see below:It seems that your question is how to find out the schema for your database; correct?

I found this https://www.sqldatadictionary.com/AdventureWorks2014.pdf
Thanks. I am just curious, I am pretty sure there was some concept named for what I was referring to: a collection of data objects assigned to a database role. e.g., there would be a container for data objects related to HR . This container would include ,would contain, among other things, all tables HumanResources. xxx.xxx. Can anyone think of the name for this, or if maybe I am remembering incorrectly?
 
  • #11
I think you have your answers @WWGD. I gave you the link to the data dictionary text in #8 and @BvU gave a link to the pictorial form in #9.

If these answers are not enough, please try to be more specific and more clear about what you are asking.
 
Last edited:
  • #12
WWGD said:
How do I import the ones that are missing?
Hi WWGD:

Sorry, I cannot help you. I don't know your database, and the techniques for accessing database diagrams and definitions vary from one to another. Good luck.

Regards,
Buzz
 
  • Like
Likes WWGD
  • #13
Hi WWGD:

I looked at the poster linked in BvU's post #9 and the schema text linked in aorlunda's post #8. Have you looked at these? If so, what are the specific problems you have in understanding the information there?

Regards,
Buzz
 
  • #14
Hi, thanks for the links. My issue was about importing missing tables into the general schema so I can create a full database diagram . It is just a general technical issue and not just about issues specific to adventureworks database. With a full diagram I can determine , for a general database, the keys I can use to make required joins.
 
  • #15
WWGD said:
Hi, thanks for the links. My issue was about importing missing tables into the general schema so I can create a full database diagram . It is just a general technical issue and not just about issues specific to adventureworks database. With a full diagram I can determine , for a general database, the keys I can use to make required joins.

As @Buzz Bloom said, the specific procedures vary with each DBMS and with each user interface. For example:
https://www.google.com/search?source=hp&ei=4ZPgWpHSNs7bzwKf2YfwBg&q=oracle+print+schema&oq=oracle+&gs_l=psy-ab.1.0.35i39k1j0i20i264k1j0i131k1l3j0j0i20i264k1j0l3.1945.3053.0.4904.8.7.0.0.0.0.162.780.3j4.7.0...0...1.1.64.psy-ab..1.7.777.0..46j0i131i20i264k1j0i46k1.0.9gy33upntaw said:
Oracle show Schema
How to list all available schemas
  • DB2. select schemaname from syscat.schemata.
  • MySQL. You can leave the schema blank since for MySQL, physically a schema is synonymous with a database.
  • Oracle. select USERNAME from SYS.ALL_USERS.
  • PostgreSQL. select nspname from pg_catalog.pg_namespace.
  • Presto. SHOW SCHEMAS [ FROM catalog ]
  • Snowflake. ...
  • SQL Server. ...

You still have deep misconceptions about database schemas. Please read the whole Wikipedia article https://en.wikipedia.org/wiki/Database_schema
 
  • #16
My apologies for not reading that post carefully enough. Still I think I do understand what a schema is and there is a related concept , at least within Sql server of a schema as a container for data objects assigned to a sspecific role, e.g, there is an hr schema containing tables and other objects related to the hr role. The use is that access to these tables is restricted to those assigned to the hr role. Roles are assigned in this way.
 
  • #17
WWGD said:
My apologies for not reading that post carefully enough. Still I think I do understand what a schema is and there is a related concept , at least within Sql server of a schema as a container for data objects assigned to a sspecific role, e.g, there is an hr schema containing tables and other objects related to the hr role. The use is that access to these tables is restricted to those assigned to the hr role. Roles are assigned in this way.

So, is your question specific to SQL Server? It sounds like you want to circumvent the security in SQL server.

You are still being very unclear, so PF members don't know how to answer your questions.

I'm going to lock this thread. Please PM me with better descriptions of your goal if you want it reopened.

Thread locked.
 
Last edited:

Related to Large Joins in Large Databases -- How to find Keys?

1. What is a large join in a database?

A large join in a database refers to the process of combining data from two or more tables based on a common key. This is often done to retrieve data that is spread across multiple tables in a database.

2. Why are large joins important in databases?

Large joins are important because they allow us to retrieve data from multiple tables, which can save time and improve the efficiency of database queries. Without large joins, we would need to manually search and combine data from different tables, which can be time-consuming and prone to errors.

3. How can I optimize large joins in a database?

There are several ways to optimize large joins in a database, such as creating indexes on the join columns, using smaller data types, and limiting the number of columns used in the join. Additionally, regularly updating statistics and optimizing the database's query execution plan can also improve the performance of large joins.

4. What are some common challenges with large joins in databases?

Some common challenges with large joins in databases include slow performance, data duplication, and compatibility issues with different database systems. Additionally, large joins can also be prone to errors and may require significant computing resources, such as memory and processing power.

5. How can I find the keys for large joins in large databases?

To find the keys for large joins in large databases, you can use tools such as database management systems or query optimization tools. These tools can help identify the relationships between tables and suggest the most efficient way to join them. Additionally, you can also consult the database's documentation or seek advice from a database expert.

Similar threads

  • Programming and Computer Science
2
Replies
51
Views
4K
  • Programming and Computer Science
Replies
7
Views
569
  • Programming and Computer Science
Replies
21
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
2
Replies
50
Views
4K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
468
Back
Top