Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17
Fill in the blanks.
a. A Database is an organized collection of data.
b. A DBMS is a software package that can be used for creating and managing databases. c. A RDBMS is a database management system that is based on the relational model. d. Three popular DBMS software are Oracle, IBM DB2, &Microsoft SQL Server. e. A table is a set of data elements that is organized using a model of vertical columns and horizontal rows. f. A column is a set of data values of a particular simple type, one for each row of the table. g. A row/record/tuple represents a single, data item in a table. h. Datatypes are used to identify which type of data we are going to store in the database. i. A primary key is a unique value that identifies a row in a table. j. Types of languages used for creating and manipulating the data in the Database are DDL&DML. k. A DDL is a standard for commands that define the different structures ina database. l. A DML is a language that enables users to access and manipulate data in adatabase. m.A query language is a part of DML involving information retrieval only. n. A popular data manipulation language is SQL. o. Common DDL statements are CREATE, ALTER, and DROP. p. Tables are the basic building blocks of a database. q. A form helps the user to systematically store information in the database. r. A form enables users to view, enter, and change data directly in database objects such as tables. s. To create a form, you need to select Forms option available under Database section. t. A query is helps to collect specific information from the pool of data in the database. u. SELECT statement retrieves zero or more rows from one or more database tables ordatabase views. v. INSERT statement is used to add one or more records to a database. w. UPDATE statement is used for modifying records in a database. x. DELETE statement is used to remove one or more records in a database. y. CREATE statement is used for creating a database or a table in any RDBMS Software. z. A report is used to generate the overall work outcome in a clear format. aa. To create reports, you need to select Use Wizard to Create Report option available under Tasks. 2. Short answer type questions. a. What is database? A database is an organized collection of data. You can visualize it as a container of information. The data is typically organized to model relevant aspects of reality. The database concept has evolved since the 1960s to ease increasing difficulties in designing, building, and maintaining complex information systems (typically with many concurrent end-users, and with a large amount of diverse data). b. Name any five popular DBMS Software? · Oracle ● IBM DB2, · Microsoft SQL Server, ●Microsoft Access, · PostgreSQL, ●MySQL, · FoxPro, ●SQLite c. Explain table in database. A table is a set of data elements that is organized using a model of vertical columns and horizontal rows. A table has a defined number of columns, but can have any number of rows. Each row is identified by the values appearing in a particular column identified as a unique key index or the key field. d. What is column? Or Explain Field. A column or Field is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed. For example, cFirstName, or cLastName are fields in a row. e. Explain Rows. Or What are tuples? Or Define Records. A row also called a record or tuple represents a single, data item in a table. In simple terms, a database table can be visualized as consisting of rows and columns or fields. Each row in a table represents a set of related data, and every row in the table has the same structure.
f. What is Primary key?
Or Explain PK. A primary key is a unique value that identifies a row in a table. Primary Keys are also indexed in the database, making it faster for the database to search for a record. g. What is Foreign key? Or Explain FK. The referred Primary key which occurs in other table is called the foreign key (FK). Hence, the foreign key identifies a column or set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. h. State the relationship and difference between a primary and foreign key. A primary key is a unique value that identifies a row in a table where foreign key is the referred primary key in another table. The “one” side of a relation is always the parent, and provides the PK attributes to be copied. The “many” sides of a relation are always the child, into which the FK attributes are copied. i. What is Forms in Database A form provides the user a systematic way of storing information into the database. It is an interface in a user specified layout that lets users to view, enter, and change data directly in database objects such as tables. j. Explain Reports in Database. A report is used to generate the overall work outcome in a clear format. You can also create reports in database. k. What is database sever? Database servers are dedicated computers that hold the actual databases and run only the DBMS and related software. Typically, databases available on the database servers are accessed through command line or graphic user interface tools referred to as Frontends; database servers are referred to as Back-ends. Such type of data access is referred to as a client-server model. l. Explain CREATE Statement with syntax. Create statement is used for creating a database or a table in any RDBMS Software. A commonly used CREATE command is the CREATE TABLE command. The general syntax of the create statement is shown below. CREATE TABLE <TABLENAME> ([column definitions]) [table parameters] m. Explain SELECT statement with Syntax A SELECT statement retrieves zero or more rows from one or more database tables or database views. In most applications, SELECT is the most commonly used Data Manipulation Language (DML) command. The SELECT statement has many optional clauses: • WHERE specifies which rows to retrieve. • ORDER BY specifies an order in which to return the rows. To retrieve all the columns in a table the syntax is: SELECT * FROM <TABLENAME>; n. What is INSERT Statement Explain with syntax. INSERT statement is used to add one or more records to a database. The general syntax of the insert statement is shown below. INSERT INTO <table_name><column1, column2, column3...> VALUES <value1, value2, value3 ...>; o. Explain UPDATE statement with syntax. Update statement is used for modifying records in a database. The general syntax of the update statement is as follows: UPDATE <table_name> SET <column_name> = value [, column_name = value ...] [WHERE <condition>] p. Explain DELETE statement with Syntax. Delete Statement is used to remove one or more records in a database. The general syntax of the delete statement is as follows: DELETE FROM <table_name> [WHERE] <condition>; 3. What is Database Management System? Explain any three DBMS Software. Or Explain DBMS. Explain the two types of data organization in DBMS. A database management system(DBMS) is a software package with computer programs that controls thecreation, maintenance, and use of a database. It allows organizations to conveniently developdatabases for various applications. A database is an integrated collection of data records, files,and other objects. A DBMS allows different user application programs to concurrently access thesame database. Well known DBMS Software are Oracle, IBM DB2, Microsoft SQL Server, Microsoft Access. Data can be organized into two types: • Flat File: Data is stored in a single table. Usually suitable for less amount of data. • Relational: Data is stored in multiple tables and the tables are linked using a common field.Relational is suitable for medium to large amount of data. 4. What is RDBMS? A relational database management system (RDBMS) is a database management system that is based on the relational model as introduced by E. F. Codd. In this model all data is represented in term of tuples/rows &columns, grouped into relations/tables. A database organized in terms of the relational model is a relational database. The purpose of the relational model is to provide a declarative method for specifying data and queries: users directly state what information the database contains and what information they want from it, and let the database management system software take care of describing data structures for storing the data and retrieval procedures for answering queries. Some RDBMS software are Oracle, MySQL, MS Access, Open Office Base, Sybase. 5. Explain Manipulating Data in Database. or What do you mean by DDL and DML commands? or What is DDL? Mention any two DDL statements. or What is DML? Explain its type. In a database you can define the structure of the data and manipulate the data using some commands. There are two types of languages for this task. These are: • Data Definition Language (DDL) • Data Manipulation Language (DML) Data Definition Language (DDL) A data definition language or data description language (DDL) is a standard for commands that define the different structures in a database. DDL statements create, modify, and remove database objects such as tables, indexes, and users. Common DDL statements are CREATE, ALTER, and DROP. Data Manipulation Language (DML) A data manipulation language (DML) is a language that enables users to access and manipulate data in a database. The goal is to provide efficient human interaction with the system • Retrieval of information from the database- SELECT statement • Insertion of new information into the database - INSERT statement • Deletion of information in the database - DELETE statement • Modification of information in the database - UPDATE statement There are two types of DML: • Procedural: The user specifies what data is needed and how to get it • Nonprocedural: The user only specifies what data is needed. This is easier for the user but may not generate code as efficient as that produced by procedural languages. 6. Explain Datatypes in Database. Datatypes are used to identify which type of data (value) we are going to store in the database. Fields themselves can be of different types depending on the data they contain. Data types in OpenOffice base is broadly classified into five categories listed below. • Numeric Types • Alphanumeric Types • Binary Types • Date time • Other Variable types Numeric Types: Numeric data types are used for describing numeric values for the field used in the table of database. Numeric data types in a database can be using for storing information such as mobile number, roll number, door number, year of school admission. · INTEGER Integer Store integer range between -2 to +2 -1 31 31 · BIGINT Big Integer Range between -263 to +263-1 · DECIMAL Decimal Maximum precision of e(+/-)231 · DOUBLE Double 2-1074 to (2-2- 52 )* 21023 Alphanumeric Types: · LONGVARCHAR Memo Stores up to the max length or number indicated by user. · CHAR Text (fix) Stores exactly the length specifiedby user. · VARCHAR Text Stores up to the specified length. Nopadding Binary Types: Binary data types are used for storing data in binary formats. Binary data types in a database can be using for storing photos, music files, etc. · LONGVARBINARY Image Stores any array of bytes (images, sounds, etc.). Novalidation required. · BINARY Binary (fix) Stores any array of bytes. No validation required. · VARBINARY Binary Stores any array of bytes. No validation required. Date time: Date time data types are used for describing date and time values for the field used in the table of a database. Date time data types in a database can be using for storing information such as date of birth, date of admission, date of product sale, etc. · Date Stores month, day and year information 1/1/99 to 1/1/9999 · Time Stores hour, minute and second information Seconds since 1/1/1970 · Timestamp Stores date and time information Other Data Types: · Other/Object Stores serialized Java objects – user application must supply serialization routines 7. Write command to create table named ‘BOOK ‘ with following fields: BOOK ID Char(4) BnameVarchar(15) Author Varchar(20) Price Decimal Ans: Create table BOOK ( BOOK_ID char(4), Bname varchar(15), Author varchar(20), Price Decimal );
8. Write an SQL query to create a table
with the following structure. Field Type Emp_no Char(4) Name Varchar(2 5) Salary Float Departme Varchar(1 nt 5) Ans: Create Table Employee(Emp_no Char(4), Name Varchar(25), Salary Float, Department Varchar(15));
9. Write SQL query to create the Table
Flight with the following structure : Field Type Flight_ID Char(4) Flight_Nam Varchar(25 e ) Source Varchar(30 ) Destination Varchar(30 ) Ans: Create Table Flight(Flight_IDChar(4), Flight_Name Varchar(25), Source Varchar(30), Destination Varhcar(30));
10. Consider the following table and answer
the following. ID Departme OPD_DAY Doctor_Na nt S me H20 ENT MWF Akaash 1 Arora H30 Oncology TTS Dharma 8 Sharma H90 Pediatrics MWF Sanjay Singh 7 (a) Identify suitable Primary Key from the above table. (b) Add a new record with the following data : (‘H608’, ‘Cardiology’, ‘TTS’, ‘Vinita Wahi’) (c) Write query to display records of those Doctors whose OPD_DAYS are‘MWF’. Ans: a) ID is the primary key from the above table. b) INSERT into <TableName> (ID, Department, OPD_DAYS, Doctor_Name) VALUES (‘H608’, ‘Cardiology’, ‘TTS’, ‘Vinita Wahi’); c) SELECT * from <TableName> WHERE OPD_DAYS =”MWF”; 11. Write the SQL commands to answer the queries based on Fabric table FabricI Fname Type Disc D F001 Shirt Woolen 10 F002 Suit Cotton 20 F003 Tunic Cotton 10 F004 Jeans Denim 5 F006 Shorts Cotton 7 a. To insert the following record (“F005”, “Kurta”, “Woollen”,5) b. To display only those fabric whose disc is more than 10. c. To display those records whose type is “Woolen”. d. To modify the fabric shirt by increasing discount by 10. e. To delete the record of fabric ‘F003’ from table. Ans: a. insert into Fabric values (‘F005’, ‘Kurta’, ‘Woollen’,5); b.: select * from Fabric where Disc>10; c. select * from Fabric where type = ‘Woollen’; d. update fabric set Disc =Disc + 10 where Fname = ‘Shirt’; e. delete from Fabric where FabricID=‘F003’; TRY YOURSELF 12. Write the answers based on the following table: Table: Manger Deptn Deptnam Name City o e S101 Sales Pranjal Delhi Sharma HR40 HR Preeti Chennai 4 Arora P204 Purchase Sukhmee Bangalor n Singh e AD990 Admin Sukanya Mumbai Kumar a. Suggest a suitable data type for the Deptname field. b. Write a query to display all the records of the table. c. Add a new record with the following details (‘S106’, ‘Sales’, “Kritika Tuteja”, “Delhi”). 13. Write the answers based on the following table : Table : Employee EmpI Name DeptI Qualificatio Se D D n x 1 Deepa 101 MCA F li Gupta 2 Rajat 101 BCA M Tyagi 3 Hari 102 B.A M Moha n 4 Harry 102 M.A M 5 Sumit 103 B.Tech M Mittal 6 Jyoti 101 M.Tech F a. Suggest a suitable data type for the field Empid and Name in the table Employee. b. Write a query to display all the records of the table for deptid = 101. c. Add a new record with the following details : (‘7’, ‘Chandan Makhija’, 102, ‘MCA’, ‘M’)