The Tables You Will Query
A board paper gives you a table and asks five things about it. This track does the same, except that the same three tables run through every page — so you spend your time on the queries instead of re-reading a new schema each time.
1Build them yourself
Type these in once and every question in this track will work on your own machine. Start with the database:
Then the three tables. dept first, because emp refers to it:
Three tables, as promised:
2emp — the main table
3dept — the second table
deptno is the column the two tables have in common, and every two-table question on this track joins on it.
4item — the unseen table
item is kept back for the full board-style sets at the end, so that you meet it the way you will meet a table in the exam hall: cold.
5Degree and cardinality
Two words a paper asks for by name. Degree is the number of columns; cardinality is the number of rows. You can read both straight off the output above — describe ends with the column count, and a select * ends with the row count.
6Four things planted on purpose
Bina Sharma, Emil Lepcha and Ishan Pradhan. Every NULL question uses them.
Emil Lepcha and Jyoti Tamang — so count(city) and count(*) disagree.
Her deptno is NULL, so she vanishes from every join. That is the point.
Department 40 exists in dept but appears in no employee row.
What is the degree and cardinality of the emp table?
If you insert one more employee, what changes?