Exercise Part B Unit 4
Exercise Part B Unit 4
Sharma
Ch-4(INTRODUCTION TO MYSQL)
EXERCISE
Ans-
DBMS RDBMS
1. Data is stored in a file 1. Data is stored in the form of tables.
3. Low levels of data security 3. There exists multiple levels of data security in an
RDBMS.
4. Data elements need to be accessed 4. Data elements can be easily accessed using SQL queries.
individually. You can also access multiple data elements with ease.
5. There is no relationship between 5. Data is stored in the form of tables which are related to
different data elements in a DBMS. each other using foreign keys.
1
Prerna R. Sharma
4. MySQL is a platform independent application which works on many operating systems like
Windows, UNIX, LINUX etc. and has compatibility with many languages including JAVA , C++, PHP,
PERL, etc.
5. MySQL is an easy to install RDBMS and is capable of handling large data sets.
ans-- Primary Key is a unique and non-null key which identify a record uniquely in table. A table can
have only one primary key. Candidate key is also a unique key to identify a record uniquely in a table but
a table can have multiple candidate keys.
Primary Key is a candidate key. A Candidate key may or may not be a primary key.
- Ans- Primary Key – is a column or group of columns in a table that uniquely identify every row in that
table.
Candidate Key – is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key
with no repeated attributes.
Alternate Key – is a column or group of columns in a table that uniquely identify every row in that table.
Foreign Key – is a column that creates a relationship between two tables. The purpose of Foreign keys is
to maintain data integrity and allow navigation between two different instances of an entity.
7. State the similarity and difference between the Primary Key, Candidate Key, Alternate Key and
Foreign Key
Ans-
Similarities
- All these Keys are very important part of Relational database model. They are used to establish and
identify relationships between tables and also to uniquely identify any record or row of data inside a
table.
Differences
Primary Key is a unique and non-null key which identify a record uniquely in table.Candidate key is also a
unique key to identify a record uniquely in a table but a table can have multiple candidate keys. ...
There can be only one Primary key for a table. Therefore all the remaining Candidate keys are known as
Alternate or Secondary keys. They can also uniquely identify tuples in a table, but the database
administrator chooses one key as the Primary key.
The main difference between the primary key and foreign key is that it identifies each record in the
table, whereas the foreign key is used to link two tables together. A foreign key always matches the
primary key column in another table. It means a foreign key column in one table refers to the primary
key column of another table.
2
Prerna R. Sharma
Ans-To open the database and to make it current and work on it ‘USE’ statements are required.
USE <databasename>;
Ans- A table is an object inside a database. A database has tables , views, indexes and programs. A
database can have 10 or thousands of tables.
database is a collection of several components like tables, indexes, stored procedures and so on. A table
is a two dimensional structure that contains columns and rows. It contains data in the form of rows and
columns
10. Write SQL statement to view names of all the tables contained in the current database
Ans- To see a list of tables present in the current database we will use SHOW TABLES.
11.In a database there is a table Cabinet. The data entry operator is not able to put NULL in a column
of Cabinet? What may be the possible reason(s)?
Ans-Because NOT NULL constraint is applied on that column in which data entry operator is trying to put
NULL value.
12.In a database there is a table Cabinet. The data entry operator is not able to put duplicate values in
a column of Cabinet? What may be the possible reason(s)?
Ans- Because Unique key constraint is applied on that column in which data entry operator is trying to
put duplicate value
14.There is a table T1 with combination of columns C1, C2, and C3 as its primary key? Is it possible to
enter:
Ans- a. No.Primary key column does not allow null values in it.
15. At the time of creation of table X, the data base administrator specified Y as the
Primary key. Later on he realized that instead of Y, the combination of column P and
Q should have been the primary key of the table. Based on this scenario, answer the
following questions:
3
Prerna R. Sharma
b. What statement(s) should be entered to change the primary key as per the
requirement.
17. Does MySQL allow to change the primary key in all cases? If there is some special
Ans- Yes, MySQL allow to change the primary key in all cases
18. What are the differences between DELETE and DROP commands of SQL?
Ans-DELETE Command is used to remove some or all the records from the table. while
DROP TABLE command is used to delete tables.Delete is DML while Drop is DDL
A. CHANGE
B. MODIFY
C. UPDATE
D. SAVE AS
A. DELETE
B. DROP
C. TRUNCATE
D. REMOVE
5. BETWEEN operator includes ____UPPER_BOUND_ and _LOWER BOUND__values given in the range.
4
Prerna R. Sharma