In: Computer Science
I need to answer all 16 questions. Please do as many as you can.
Please answer the following question of database
management.
1. Describe the process of creating a table in SQL and the
different data types you can use for fields.
2. What is the purpose of the WHERE clause in SQL? Which
comparison operators can you use in a WHERE clause?
3. How do you write a compound condition in an SQL query? When is a
compound condition true?
4. What is a computed field? How can you use one in an SQL query? How do you assign a name to a computed field?
6. How do you use the IN operator in an SQL query?
7. How do you sort data in SQL? When there is more than one sort key, how do you indicate which one is the major sort key? How do you sort data in descending order?
8. What are the SQL built-in functions? How do you use them in an
SQL query?
9. What is a subquery? When is a subquery executed?
10. How do you group data in SQL? When you group data in SQL, are
there any restrictions on the items that you can include in the
SELECT clause? Explain.
11. How do you join tables in SQL?
12. In a complex join, how is the number of tables you wish to join related to the number of WHERE conditions?
13. How do you qualify the name of a field in an SQL query? When is it necessary to do so?
14. How do you take the union of two tables in SQL? What criteria must the tables meet to make a union possible?
15. Describe the three update commands in SQL.
16. How do you save the results of an SQL query as a table?
1. In SQL the table can be created using a command CREATE TABLE command.
Following is the format:
CREATE TABLE "table name"
( "column1" "datatype(size)",
"column2" "datatype(size)",
"column3" "datatype(size)"
);
Ex: Student table.
CREATE TABLE student(
id int(20),
name varchar(20),
address varchar(20)
);
Below are the few measures to be taken while creating a table:
The datatypes we can use for fields are:
i. Integer
ii. Real(floating point)
iii. Text(String or text)
For the combination of string and number we use varchar.
2.The SQL WHERE clause is used to specify a condition while fetching the data from a single table or by joining with multiple tables. ... The WHERE clause is not only used in the SELECT statement, but it is also used in the UPDATE, DELETE statement, etc.,
-->The comparison operators are;
>,>=,<,<=,=,<>(not equal).
3.To write a compound condition, one would use the operators AND and OR to connect two simple conditions. A compound condition is true when the simple condition is met, i.e. one wants all the results that exactly match a certain parameter or criteria.
4a).Computed Field:
i) A field who's data is retrieved from the data of other field.
ii)It is also known as calculated field.
iii) Computed values are not physically present in the database.
iv) The operations involved in this are addition, Subtraction, Multiplication and division.
4b) In order to find the top 1 value in the table we use one(1)
Ex: SELECT TOP 1 "column name"
FROM "Table name"
4c) To find the computed field, We need to first identify the field values and the operations that are used for calculating the computed field . SQL aliasing can be used o give a name to the computed field.
6.The SQL IN condition (sometimes called the IN operator) allows you to easily test if an expression matches any value in a list of values. It is used to help reduce the need for multiple OR conditions in a SELECT, INSERT, UPDATE, or DELETE statement.
8.COUNT,SUM,AVG,MAX,MIN are the built-in functions provided by Sql Server.
Hope your are satisfied with the answers. please give a like.