[ Prev ]
2019-11-13

-- Nov 13 In-Class Exercise Thread
1) SELECT * FROM EMPLOYEES WHERE employee.name AND year.started 2) SELECT * FROM EMPLOYEES JOIN employee.name ON year.started
2nd method is better because this table joins employee name with year started directly without creating tuples started in 1st method.
1) SELECT * FROM EMPLOYEES WHERE employee.name AND year.started 2) SELECT * FROM EMPLOYEES JOIN employee.name ON year.started 2nd method is better because this table joins employee name with year started directly without creating tuples started in 1st method.

-- Nov 13 In-Class Exercise Thread
Car(no_wheels,name) Truck(no_wheels,name)
	
1) Select * from Car, Truch Where Car.no_wheels=truck_wheels
2) select * from (Car Join Truk on Car.no_wheels = Truk.no_wheels)
Car(no_wheels,name) Truck(no_wheels,name) 1) Select * from Car, Truch Where Car.no_wheels=truck_wheels 2) select * from (Car Join Truk on Car.no_wheels = Truk.no_wheels)
2019-11-17

-- Nov 13 In-Class Exercise Thread
1)SELECT * FROM Students, Singers WHERE Students.name = Singers.name; 2) SELECT * FROM (Students JOIN Singers ON Students.name = Singers.name); - Query 2 is better because the operations that are being performed on the relations are shown. Query 1 implies a compute join, but query 2 shows a join based on given conditions.
1)SELECT * FROM Students, Singers WHERE Students.name = Singers.name; 2) SELECT * FROM (Students JOIN Singers ON Students.name = Singers.name); - Query 2 is better because the operations that are being performed on the relations are shown. Query 1 implies a compute join, but query 2 shows a join based on given conditions.

-- Nov 13 In-Class Exercise Thread
Drinker(name, address, favBeer)
Beer(name, manufacturer, category)
I want to find the name, address of the drinkers who favorite a beer made by Anheuser Bush
1. SELECT Drinker.name and Drinker.address FROM Drinker, Beer WHERE drinker.favBeer = Beer.name, manufacturer = 'Anheuser Bush';
2. SELECT Drinker.name and Drinker.address FROM Drinker JOIN Beer ON (drinker.favBeer = Beer.name) WHERE manufacturer = 'Anheuser Bush';
The second query is more effective and readable since we can see the join table before getting the result of the query
Drinker(name, address, favBeer) Beer(name, manufacturer, category) I want to find the name, address of the drinkers who favorite a beer made by Anheuser Bush 1. SELECT Drinker.name and Drinker.address FROM Drinker, Beer WHERE drinker.favBeer = Beer.name, manufacturer = 'Anheuser Bush'; 2. SELECT Drinker.name and Drinker.address FROM Drinker JOIN Beer ON (drinker.favBeer = Beer.name) WHERE manufacturer = 'Anheuser Bush'; The second query is more effective and readable since we can see the join table before getting the result of the query

-- Nov 13 In-Class Exercise Thread
 SELECT Price, Model FROM Models, Products WHERE modelId = productId;
 SELECT Price, Model FROM Models JOIN Products ON modelId = productId); 
 
 Join's syntax seems to be easier to intuitively understand off of just reading. Using the word JOIN specifies there is some combining going on, where as without it its just implied  
(Edited: 2019-11-18)
SELECT Price, Model FROM Models, Products WHERE modelId = productId; SELECT Price, Model FROM Models JOIN Products ON modelId = productId); Join's syntax seems to be easier to intuitively understand off of just reading. Using the word JOIN specifies there is some combining going on, where as without it its just implied

-- Nov 13 In-Class Exercise Thread
SELECT Name FROM Classes,Professors WHERE name='courseID' SELECT Name FROM Classes FULL OUTER JOIN Professors ON Name = Professors.name AND = Name = Classes.pName It is better to use a join, because it is unclear which name should be used. If the Classes table has a name called "name", and Professor table has a Professor name called "name", it would be difficult to distinguish which name is referring to which column.
SELECT Name FROM Classes,Professors WHERE name='courseID' SELECT Name FROM Classes FULL OUTER JOIN Professors ON Name = Professors.name AND = Name = Classes.pName It is better to use a join, because it is unclear which name should be used. If the Classes table has a name called "name", and Professor table has a Professor name called "name", it would be difficult to distinguish which name is referring to which column.

-- Nov 13 In-Class Exercise Thread
1. SELECT * FROM Singers, Muscianist WHERE name = artist
2. SELECT * FROM Singers JOIN Muscianist ON name = artist
The JOIN ON syntax explicitly shows the cartesian between the two tables. The first query also does a join, but the second one is more explicit.
1. SELECT * FROM Singers, Muscianist WHERE name = artist 2. SELECT * FROM Singers JOIN Muscianist ON name = artist The JOIN ON syntax explicitly shows the cartesian between the two tables. The first query also does a join, but the second one is more explicit.
X