Computer Science - V: Disadvantages of Database System Are
Computer Science - V: Disadvantages of Database System Are
Computer Science -V
Short answers Q.1. What is transaction? What guarantee does a DBMS offer with respect to transactions? A transaction is a "sequence of operations performed as a single logical unit of work". A transaction has four key properties that are abbreviated ACID. ACID is an acronym for for Atomic Consistent Isolated Durability. Atomic means that all the work in the transaction is treated as a single unit. Either it is all performed or none of it is. Consistent means that a completed transaction leaves the dat abase in a consistent internal state. Isolations means that the transaction sees the database in a consistent state. This transaction operates on a consistent view of the data. If two transactions try to update the same table, one will go first and then the other will follow. Durability means that the results of the transaction are permanently stored in the system. Q.2. What are the disadvantages of a database system?
Q.4. Why are tuples I a relation not ordered? A relation is defined as a set of tuples. Mathematically, elements of a set have no order among them; hence, tuples in a relation do not have any particular order. In other words, a relation is not sensitive to the ordering of tuples. Tuple ordering is not part of a relation definition because a relation attempts to represent facts at a logical or abstract level. Many logical orders can be specified on a relation but there is no preference for one logical ordering over another.
Computer Science -V
Q.5. State the difference between key and super key. Superkey is any subset of attributes that uniquely identifies the tuples of a relation. This subset need not be minimal, that is, one can remove some attributes from it and it is still uniquely identifying. If all redundant attributes are removed you get a subset what is called primary key. A key (better: primary key) is the minimal subset of attributes that uniquely identifies the tuples of a relation, that is, you can't remove further attributes from this subset without losing the property of unique Identification. Therefore, the super superkey (like superman) is always the set of all attributes of a relation. Q.6. What do you mean by logical data independence? Logical data independence: The ability to change the logical (conceptual) schema without changing the External schema (User View) is called logical data independence. For example, the addition or removal of new entities, attributes, or relationships to the conceptual schema should be possible without having to change existing external schemas or having to rewrite existing application programs.
Q.8. List data types that are allowed for SQL attributes.
Data Type
integer smallint numeric Integer Smallint
Syntax
Explanation
numeric(p,s)
Where p is a precision value; s is a scale value. For example, numeric(6,2) is a number that has 4 digits before the decimal and 2 digits after the decimal. Where p is a precision value; s is a scale value. Single-precision floating point number Double-precision floating point number Where p is a precision value. Where x is the number of characters to store. This data type is space padded to fill the number of characters specified.
Computer Science -V
character varying varchar2(x) Where x is the number of characters to store. This data type does NOT space pad. Where x is the number of bits to store. Where x is the number of bits to store. The length can vary up to x. Stores year, month, and day values. Stores the hour, minute, and second values. Stores year, month, day, hour, minute, and second values. Exactly the same as time, but also stores an offset from UTC of the time specified.
timestamp with time zone timestamp with time zone Exactly the same as timestamp, but also stores an offset from UTC of the time specified. year-month interval day-time interval Contains a year value, a month value, or both. Contains a day value, an hour value, a minute value, and/or a second value.
Computer Science -V
for ex, emp_table empno empname salary deptno
In the above relation, deptno is there in emp_table which is a primary key of dept_table. that means, deptno is refering the dept_table.
MARKETING_CUST). It can also occur if repeatable data types are contained within repeating fields, and not segregated into their own tables and related by a unique ID key (ie; ID_CUST, or CUST_ID).
Computer Science -V
Based on functional dependencies among the attributes of a relation, a relation can be normalized to a specific form to prevent the possible occurrence of update anomalies.
Q.14. Define concurrent access. Q.15. Differentiate between CHAR and VARCHAR.
CHAR is used for fixed length memory storage whereas VARCHAR is used for variable lenght memory storage. For Example if we have char(10) then we can store 10 bit value in it but if we store only 6 bit value in it then rest of the 4 bit space goes wasted. This limitation is overcome by VARCHAR. In VARCHAR if we use less space than defined space the rest of the space is not wasted.
Long answers
Q.1. Explain R.F code.
Codd's rules are proposed by Edgar F. Codd, a pioneer of the relational model for databases, designed to define what is required from a database management system in order for it to be considered relational, i.e., a relational database management system (RDBMS) Rule (0): The system must qualify as relational, as a database, and as a management system. For a system to qualify as a relational database management system (RDBMS), that system must use its relational facilities to manage the database. Rule 1: The information rule: All information in the database is to be represented in only one way, namely by values in column positions within rows of tables. Rule 2: The guaranteed access rule:
Computer Science -V
All data must be accessible. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual scalar value in the database must be logically addressable by specifying the name of the containing table, the name of the containing column and the primary key value of the containing row. Rule 3: Systematic treatment of null values: The DBMS must allow each field to remain null (or empty). Specifically, it must support a representation of "missing information and inapplicable information" that is systematic, distinct from all regular values (for example, "distinct from zero or any other number", in the case of numeric values), and independent of data type. It is also implied that such representations must be manipulated by the DBMS in a systematic way. Rule 4: Active online catalog based on the relational model: The system must support an online, inline, relational catalog that is accessible to authorized users by means of their regular query language. That is, users must be able to access the database's structure (catalog) using the same query language that they use to access the database's data. Rule 5: The comprehensive data sublanguage rule: The system must support at least one relational language that 1. Has a linear syntax 2. Can be used both interactively and within application programs, 3. Supports data definition operations (including view definitions), data manipulation operations (update as well as retrieval), security and integrity constraints, and transactionmanagement operations (begin, commit, and rollback). Rule 6: The view updating rule: All views that are theoretically updatable must be updatable by the system. Rule 7: High-level insert, update, and delete: The system must support set-at-a-time insert, update, and delete operators. This means that data can be retrieved from a relational database in sets constructed of data from multiple rows and/or multiple tables. This rule states that insert, update, and delete operations should be supported for any retrievable set rather than just for a single row in a single table. Rule 8: Physical data independence:
Computer Science -V
Changes to the physical level (how the data is stored, whether in arrays or linked lists etc.) must not require a change to an application based on the structure. Rule 9: Logical data independence: Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure. Logical data independence is more difficult to achieve than physical data independence. Rule 10: Integrity independence: Integrity constraints must be specified separately from application programs and stored in the catalog. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications. Rule 11: Distribution independence: The distribution of portions of the database to various locations should be invisible to users of the database. Existing applications should continue to operate successfully : 1. when a distributed version of the DBMS is first introduced; and 2. when existing distributed data are redistributed around the system. Rule 12: The nonsubversion rule: If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint.
Q.2. Why do we designate one of the candidate keys of a relation to be the primary key? Q.3. Explain the term: a) Logical schema b) Physical schema.
Logical schema: A logical schema is an alias that allows a unique name to be given to all the physical schemas containing the same datastore structures. The aim of the logical schema is to ensure the portability of the procedures and models on the different physical schemas. In this way, all developments in Designer are carried out exclusively on logical schemas. A logical schema can have one or more physical implementations on separate physical schemas, but they must be based on data servers of the same technology. A logical schema is always directly linked to a technology. To be usable, a logical schema must be declared in a context. Declaring a logical schema in a context consists of indicating which physical schema corresponds to the alias - logical schema - for this context.
Computer Science -V
Physical Schema: Physical schema is a term used in data management to describe how data is to be represented and stored (files, indices, et. al) in secondary storage using a particular database management system.
Q.4. How is the log used in transaction rollback and crash recovery?
The SQL Server transaction log operates logically as if the transaction log is a string of log records. Each log record is identified by a log sequence number(LSN). Log records are stored in a serial sequence as they are created. Each log record contains the ID of the transaction that it belongs to. For each transaction, all log records associated with the transaction are individually linked in a chain using backward pointers that speed the rollback of the transaction. Rollback operations are also logged. Each transaction reserves space on the transaction log to make sure that enough log space exists to support a rollback that is caused by either an explicit rollback statement or if an error is encountered. The amount of space reserved depends on the operations performed in the transaction, but generally is equal to the amount of space used to log each operation. This reserved space is freed when the transaction is completed.
Crash recovery:
A database can be damaged in a number of ways such as by a power failure or an operator error in bringing down the server. When an event like this happens, SQLBase tries to restore the database to a consistent state by performing crash recovery automatically when a user attempts to connect. Crash recovery consists of using the transaction logs to redo any committed transactions which had not yet been written to the database and to undo any uncommitted transactions which were active when the server crashed. There are situations where SQLBase will not be able to return a database to a consistent state, such as when the transaction logs have been damaged during a media failure, or if transaction logging has been disabled by the operator. Use the fail.sql file to review information. This file contains information regarding failure and error situations that occur, generated by SQLBase, and should be reviewed any time an unusual event occurs with the database.
Q.5. Explain packages and its types by taking example. A package is a schema object that groups logically related PL/SQL types, items, and subprograms. Packages usually have two parts, a specification and a body, although sometimes the body is unnecessary. The specification (spec for short) is the interface to your applications; it declares the types, variables, constants, exceptions, cursors, and subprograms available for use. The body fully defines cursors and subprograms, and so implements the spec.
Q.6.Explain the advantages of using a query language instead of custom programs to process data.
Computer Science -V
Query language more-so (SQL) is a way of looking for information on a given criteria whereas custom programs tend to have hard coded search processes. Addition to this, SQL, Oracle etc languages are tailored to the programmer not the user so during the development stages, adaptations can be made for the program and at this point it can be developed to be as efficient as the programmer can make it. A query language can be used by thousands or even millions of people, whereas a custom program can be used by a limited few. Query languages are in fact high-level programming languages, dedicated database languages that considerably simplify writing database application programs. Database languages also simplify the database organization as well as retrieving and presenting information from it. Queries allow the user to describe desired data, leaving the database management system (DBMS) responsible for planning, optimizing, and performing the physical operations necessary to produce that result as it chooses. Custom software may not follow standard protocols and be unable to interact with other programs effectively. The help files may be lacking and support would be more difficult to come by, considering the uniqueness of the program. If the programmer of a custom program leaves the company the software will no longer be update-able. Cost effects on upgrades and maintenance are high.
Q.7. List the various cases where use of null value would be appropriate. Q.8. Discuss the main characteristics of the database approach.
Main Characteristics of the database approach Self-describing nature of a database system:
A fundamental characteristic of the database approach is that the database system contains not only the database structure and constrains. this definition is stored in the system catalog. A DBMS catalog stores the description of a particular database (e.g. data structures, types, and constraints) The description is called meta-data.This allows the DBMS software to work with different database application.
Data abstraction:
The characteristic that allows program-data independence and program-operation independence is called data abstraction. A data model is a type of data abstraction that is used to hide storage details and present the users with a conceptual view of the database.
10
Computer Science -V
Sharing of data and multi-user transaction processing:
Allowing a set of concurrent users to retrieve from and to update the database. Concurrency control within the DBMS guarantees that each transaction is correctly executed or aborted. Recovery subsystem ensures each completed transaction has its effect permanently recorded in the database. OLTP (online Transaction Processing) is a major part of database applications.This allows hundreds of concurrent transactions to execute per second.
Consider the following relation and determinants. R(a,b,c,d) a,c -> b,d a,d -> b Here, the first determinant suggests that the primary key of R could be changed from a,b to a,c. If this change was done all of the non-key attributes present in R could still be determined, and therefore this change is legal. However, the second determinant indicates that a,d determines b, but a,d could not be the key of R as a,d does not determine all of the non key attributes of R (it does not determine c). We would say that the first determinate is a candidate key, but the second determinant is not a candidate key, rd and thus this relation is not in BCNF (but is in 3 normal form). Example: Conisder a database table that stores employee information and has the attributes employee_id, first_name, last_name, title. In this table, the field employee_id determines first_name and last_name. Similarly, the tuple (first_name, last_name) determines employee_id.
Q.9. What is view? Explain different types of views by taking suitable examples.
A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words, there is no stored file that directly represents the view instead a definition of view is stored in data dictionary. Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users from the effects of restructuring and growth in the database. Hence accounts for logical data independence.
11
Computer Science -V
A database view displays one or more database records on the same page. A view can display some or all of the database fields. Views have filters to determine which records they show. Views can be sorted to control the record order and grouped to display records in related sets. Views have other options such as totals and subtotals. Most users interact with the database using the database views. A key to creating a useful database is a well-chosen set of views. Luckily, while views are powerful, they are also easy to create. There are two types of views: 1. simple view 2. complex view
Q . 1 0 . W RI TE E R DI AG R AM FO R HO S P I T AL M AN AG E ME NT S YS TE M.
12
Computer Science -V
13
Computer Science -V
Q.12. How are the Outer Join Operations different than the Inner Join operations? How is the Outer Join operation different from Union?