DB Lab2
DB Lab2
DATABASE SYSTEMS
LAB 02
Entity: A thing of significance about which information needs to be known. Examples are
departments, employees, and orders.
Attribute: Something that describes or qualifies an entity. For example, for the employee entity,
the attributes would be the employee number, name, job title, hire date, department number, and
so on. Each of the attributes is either required or optional.
Relationship: A named association between entities showing optionality and degree. Examples
are employees and departments, and orders and items.
Primary Key: A primary key is a single attribute or a collection of attributes which is used to
distinguish—that is, uniquely identify the entity.
A SELECT statement retrieves information from the database. With a SELECT statement, you
can use the following capabilities:
• Projection: Choose the columns in a table that are returned by a query. Choose as few or as
many of the columns as needed
• Selection: Choose the rows in a table that are returned by a query. Various criteria can be used
to restrict the rows that are retrieved.
• Joining: Bring together data that is stored in different tables by specifying the link between
them.
Literal Character Strings: A Literal is a character, a number or a date that is included in the
select list and that is not a column name or column alias. We can use literal with concatenation
operator and with column names. Date and character literals must be enclosed by single
quotation marks (' '); number literals need not be so enclosed.
Alternative Quote (q) Operator: Many SQL statements use character literals in expressions or
conditions. If the literal itself contains a single quotation mark, you can use the quote (q)
operator.
LAB TASKS
True/False
True/False
3. There are four coding errors in the following statement. Can you identify them?
4. Write a query that return all columns and all records of department table.
6. Get all employees with their name and hire date, change the column heading of hire date
column.
7. Write a query that display all unique job codes from Employee table.
8. Write a query that print all employees and their job IDs, Display the last name concatenated
with the job ID (separated by a comma and space) and name of the column Employee and Title.
9. To familiarize yourself with the data in the EMPLOYEES table, create a query to display all
the data from that table. Separate each column output by a comma. Name the column title
THE_OUTPUT.