Need resources for ER diagram and SQL

In summary, the conversation is about finding resources for creating ER diagrams and relational models for SQL databases, as well as understanding SQL queries. The group discusses difficulties with creating correct ER diagrams and understanding the logic behind SQL queries, such as left join, right join, aliases, and the where operator. They also mention the importance of selecting columns that actually exist in the table and using specific table names when selecting generalized column names. They suggest experimenting and practicing with queries to gain a better understanding.
  • #1
late347
301
15
I have a gut feeling that I will retake a test about these subjects.

Do you know good resources about creating ER diagram and relational model for database (sql database primarily)

Sometimes even creating a correct ER Diagram (chen notation) feels difficult and confusing. These type of homework problems have been things like word problems where we must construvt the ER diagram from a short written description.

For relational model... I think I can create relational model when I have the correctly defined ER diagram from which to begin work...

I think I could also use some resources for SQL queries but I do know already some basic queries. I studied some basic queries at w3school and I took the quiz about SQL but still I don't really have good enough understanding for a test at our school.

But I don't quite fully understand the logic begind the queries. Especially
Left join, right join, aliases, inner join,

And the logic begind the where operator in SQL queries is a little bit fuzzy to me. Especially if you somehow combine multiple tables in a query. How are you supposed to know which fields(?) Are equal to which fields in let's say two tables...?
 
Technology news on Phys.org
  • #2
late347 said:
And the logic begind the where operator in SQL queries is a little bit fuzzy to me. Especially if you somehow combine multiple tables in a query. How are you supposed to know which fields(?) Are equal to which fields in let's say two tables...?

This is about WHERE syntax, right?

For example, when you have 2 tables and you run this query:
Code:
SELECT * FROM TABLE1, TABLE2

you'll get the output rows, which each made of every row in TABLE1 paired with every row in TABLE2.

So when you run another query like this:
Code:
SELECT * FROM TABLE1, TABLE2
WHERE COLUMN_A = COLUMN_B

basically it'll give you the same result as previous query, except that it checks that in every row, the paired ones have two column values that are equal.

My suggestion is, try it out! It'll make more sense.
 
  • #3
shadowshed said:
This is about WHERE syntax, right?

For example, when you have 2 tables and you run this query:
Code:
SELECT * FROM TABLE1, TABLE2

you'll get the output rows, which each made of every row in TABLE1 paired with every row in TABLE2.

So when you run another query like this:
Code:
SELECT * FROM TABLE1, TABLE2
WHERE COLUMN_A = COLUMN_B

basically it'll give you the same result as previous query, except that it checks that in every row, the paired ones have two column values that are equal.

My suggestion is, try it out! It'll make more sense.
What do you mean by column a and column b.

In which table is what column?Okay when you press select * from table1,table2;That means that your result is everything from both of the tables...
 
  • #4
I mean TABLE1.COLUMN_A and TABLE2.COLUMN_B
 
  • #5
shadowshed said:
I mean TABLE1.COLUMN_A and TABLE2.COLUMN_B

okay since you now changed the query.

I know that select portion chooses those columns which we want in the result. Eg.

select name,age from table1;
this kind of query would probably show in the results, the name column and the age column from that table1.

my understanding is that in the from portion. It is required that you select some column, which actually exists in that table where from you are selecting.
If you have generalized column names such as "name" such that for example...
name column appears in table1, and also in table2.
Then you get an error if you simply select using "name ". My understanding is that you need to specify it further such as...

select table1.name, table2.name from table1, table2;
This query would select both each name column from table1 and table2

basically it'll give you the same result as previous query, except that it checks that in every row, the paired ones have two column values that are equal.

My suggestion is, try it out! It'll make more sense.

that was a little bit confusing. What are the "paired ones" ?
Which exact things are equal to each other?
 
  • #6
late347 said:
okay since you now changed the query.

I know that select portion chooses those columns which we want in the result. Eg.

select name,age from table1;
this kind of query would probably show in the results, the name column and the age column from that table1.

my understanding is that in the from portion. It is required that you select some column, which actually exists in that table where from you are selecting.
If you have generalized column names such as "name" such that for example...
name column appears in table1, and also in table2.
Then you get an error if you simply select using "name ". My understanding is that you need to specify it further such as...

select table1.name, table2.name from table1, table2;
This query would select both each name column from table1 and table2

Yes, you are correct.
that was a little bit confusing. What are the "paired ones" ?
Which exact things are equal to each other?

Hmm, what I call as "paired ones" are table1's rows X table2's rows.
I believe you noticed that when you tried it before.

So in the second query, we added a constraint WHERE TABLE1.COLUMN_A = TABLE2.COLUMN_B. The query executes the SELECT function first, and then it checks on every row, filtering out rows that doesn't match the constraint.

If you still quite don't get it, try to play and run it.
 

Related to Need resources for ER diagram and SQL

1. What is an ER diagram and why is it important?

An ER diagram, or Entity-Relationship diagram, is a visual representation of the relationships between entities in a database. It is important because it helps to organize and understand the structure of the database, making it easier to design and maintain.

2. How do I create an ER diagram?

There are various software tools available to help create ER diagrams, such as Lucidchart, Draw.io, and Microsoft Visio. You can also create one manually using pen and paper or by using a whiteboard.

3. What are the essential components of an ER diagram?

The essential components of an ER diagram include entities, attributes, and relationships. Entities are the objects or concepts in the database, attributes are the characteristics of the entities, and relationships are the connections between entities.

4. What is SQL and how is it used with ER diagrams?

SQL, or Structured Query Language, is a programming language used to manage data in relational databases. It is used with ER diagrams as it allows users to create, modify, and query databases based on the relationships and structure represented in the ER diagram.

5. Where can I find resources for learning ER diagrams and SQL?

There are many online resources available for learning ER diagrams and SQL, such as tutorials, articles, and video courses. Some popular websites include W3Schools, Codecademy, and Udemy. You can also find books and attend workshops or classes on these topics.

Similar threads

  • Programming and Computer Science
Replies
5
Views
2K
  • STEM Academic Advising
Replies
1
Views
704
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
Back
Top