* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Rule 3: Systematic Treatment of NULL values
Concurrency control wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Clusterpoint wikipedia , lookup
Q-1 PL/SQL data types PL/SQL variables, constants and parameters must have a valid data types which specifies a storage format, constraints, and valid range of values. Numeric Data types & Subtypes Data type Range Dec(p,s) Upto 38 digits Decimal(p,s) Upto 38 digits Number(p,s) Upto 38 digits Numeric(p,s) Upto 38 digits Integer Int Real Float Upto 38 digits Upto 38 digits Upto 18 digits Upto 38 digits Binary_float Single precision IEEE 754 format floating point number double precision IEEE 754 format floating point number Binary_double Character Data types & Subtypes Data type Range Char Upto 32767 bytes Varchar2 Upto 32767 bytes Raw Long Raw Nchar Upto 32767 bytes Upto 2 gb Upto 32767 bytes Nvarchar2 Upto 32767 bytes Rowid Format is BBBBBBB.RRRR.FFFF Where BBBBBBB is bloack in the database file. RRRR is row in block FFFF is database file Urowid Description Where p is the precision and s is the scale e.g : decimal(4,2) o/p: 00.00 Where p is the precision and s is the scale e.g : decimal(4,2) o/p: 00.00 Where p is the precision and s is the scale e.g : decimal(4,2) o/p: 00.00 Where p is the precision and s is the scale e.g : decimal(4,2) o/p: 00.00 ANSI and IBM specific type ANSI and specific type Floating point type ANSI and IBM specific floating point type Description Fixed-length character length Varible-length character length Variable byte string Variable byte string Fixed length national character string Variable length national character string Fixed length binary data Universal row identifier. Large Object (LOB) Data types Data type Range BFILE Upto 4 gb BLOB Upto 128 tb CLOB Upto 128 tb NCLOB Upto 128 tb Date Data types Data type Date Description Used to store large binary objects in Operating System files outside the database Used to store large binary objects in the database Used to store large binary objects in the database Used to store large binary objects in the database Range Valid Dates range from 1st January 4712 to 31st December 9999. Description Default format is ‘DD-MON-YY’. Q-2 PL/SQL control structures Conditional control Iterative Control Sequential If..Else statement Loop…End loop While statement For statement Goto statment Q-7 How to secure data from others users in PL/SQL. GRANT GRANT privileges ON tablename TO username WITH Grant option REVOKE Revoke privileges ON tablename FROM username Q-5 Advantages of PL/SQL SQL is the standard database language and PL/SQL is strongly integrated with SQL. PL/SQL supports both static and dynamic SQL. Static SQL supports DML operations and transaction control from PL/SQL block. Dynamic SQL is SQL allows embedding DDL statements in PL/SQL blocks. PL/SQL allows sending an entire block of statements to the database at one time. This reduces network traffic and provides high performance for the applications. PL/SQL give high productivity to programmers as it can query, transform, and update data in a database. PL/SQL saves time on design and debugging by strong features, such as exception handling, encapsulation, data hiding, and object-oriented data types. Applications written in PL/SQL are fully portable. PL/SQL provides high security level. It offers extensive error checking. It offers numerous data types. PL/SQL provides access to predefined SQL packages. PL/SQL provides support for Developing Web Applications and Server Pages. PL/SQL provides a built-in interpreted and OS independent programming environment. PL/SQL can also directly be called from the command-line SQL*Plus interface. Direct call can also be made from external programming language calls to database. PL/SQL's general syntax is based on that of ADA and Pascal programming language. It offers a variety of programming structures. It supports structured programming through functions and procedures. It supports object oriented programming. It supports developing web applications and server pages. Q-8 Data constraints (1) Entity Data Integrity Constraints (i) Primary key (ii) Unique (2) Domain Constraints : (i)Null and Not Null Value (iv) Check (3) Referential Integrity Constraints (4) User defined integrity constraints Q-9 Aggreagate functions Max, Min, Avg , Count, Sum Q-8 TYPES OF CONSTRAINTS A constraint is a property assigned to a column or the set of columns in a table which prevent certain type of inconsistent data values. Constraints are used to enforce the data integrity. This ensures the accuracy and reliability of data in the database. (1) (2) (3) (4) Entity Data Integrity Constraints (i) Primary key (ii) Unique Domain Constraints : (i)Null and Not Null Value (iv) Check Referential Integrity Constraints User defined integrity constraints (1) Entity Data Integrity Constraints (i) Primary key : It is used to identify unique values. It does not allow null and duplicate values. A table contains only one primary key. A single column primary key is known as simple primary key where as the multiple columns primary key is known as composite primary key. Primary key constraints defined at column level Syntax: column datatype primary key Example: create table emp (empid number primary key); Primary key constraints defined at table level Syntax: primary key ( column ) Example: create table emp (empid number, empname text(30) primary key (empid)); (ii) Unique Value: It does not allow duplicate value but it allow multiple null values. A table can have more than one unique key. Unique key can combine up to 16 columns in a composite unique key. Unique key constraints defined at column level Syntax: column datatype unique Example: create table emp (empid , number primary key, mobile_no text(12) unique); Unique key constraints defined at table level Syntax: primary key ( column ) Example: create table emp (empid number, mobile_no text(30) unique (mobile_no)); (2) Domain Constraints : (i)Null and Not Null Value (ii) Check Domain integrity enforces valid entries for a given column by restricting the type, format or range of possible values. (i) Null and Not Null Null values: By default it is null but it is different from blank and zero. It is appropriate when actual value is not known Not Null values: It means that column can not be left empty. If column define as not null it means that value must be entered into the column. Syntax: column datatype not null Example: create table emp (empid , number primary key,empname text(12) not null); (ii) Check : Business rules can be applied using check constraints. It is used to specify as logical expression that evaluate either true or false result. Check constrains defined at column level. Syntax: column datatype check (logical expression) Example: create table emp (empid , number primary key,empname text(12) not null); Check constrains defined at table level. Syntax: check (logical expression) Example: create table emp (empid , number primary key check(<=500), empname text(12) ); (3) Referential Integrity Constraints Referential integrity constraints ensures that rows cannot be deleted which are used by other records. Foreign key used to enforce referential integrity constraints. Foreign key represent relationships between tables. A foreign key is a column whose values are derived from the primary key of some other table. Foreign key constrains defined at column level Syntax: column reference tablename(column) on delete cascade Example: create table position (empid , number reference emp.emp_id); Foreign key constrains defined at table level Syntax: foreign key column references tablename(column) Example: (foreign empid references emp.emp_id); (4) User defined integrity constraints: User defined integrity constraints enforces some specific business rules that do not fall into entity, domain or referential integrity categories. Codd's 12 Rules Dr Edgar F. Codd did some extensive research in Relational Model of database systems and came up with twelve rules of his own which according to him, a database must obey in order to be a true relational database. These rules can be applied on a database system that is capable of managing is stored data using only its relational capabilities. This is a foundation rule, which provides a base to imply other rules on it. Rule 1: Information rule This rule states that all information (data), which is stored in the database, must be a value of some table cell. Everything in a database must be stored in table formats. This information can be user data or meta-data. Rule 2: Guaranteed Access rule This rule states that every single data element (value) is guaranteed to be accessible logically with combination of table-name, primary-key (row value) and attributename (column value). No other means, such as pointers, can be used to access data. Rule 3: Systematic Treatment of NULL values This rule states the NULL values in the database must be given a systematic treatment. As a NULL may have several meanings, i.e. NULL can be interpreted as one the following: data is missing, data is not known, data is not applicable etc. Rule 4: Active online catalog This rule states that the structure description of whole database must be stored in an online catalog, i.e. data dictionary, which can be accessed by the authorized users. Users can use the same query language to access the catalog which they use to access the database itself. Rule 5: Comprehensive data sub-language rule This rule states that a database must have a support for a language which has linear syntax which is capable of data definition, data manipulation and transaction management operations. Database can be accessed by means of this language only, either directly or by means of some application. If the database can be accessed or manipulated in some way without any help of this language, it is then a violation. Rule 6: View updating rule This rule states that all views of database, which can theoretically be updated, must also be updatable by the system. Rule 7: High-level insert, update and delete rule This rule states the database must employ support high-level insertion, updation and deletion. This must not be limited to a single row that is, it must also support union, intersection and minus operations to yield sets of data records. Rule 8: Physical data independence This rule states that the application should not have any concern about how the data is physically stored. Also, any change in its physical structure must not have any impact on application. Rule 9: Logical data independence This rule states that the logical data must be independent of its user’s view (application). Any change in logical data must not imply any change in the application using it. For example, if two tables are merged or one is split into two different tables, there should be no impact the change on user application. This is one of the most difficult rule to apply. Rule 10: Integrity independence This rule states that the database must be independent of the application using it. All its integrity constraints can be independently modified without the need of any change in the application. This rule makes database independent of the front-end application and its interface. Rule 11: Distribution independence This rule states that the end user must not be able to see that the data is distributed over various locations. User must also see that data is located at one site only. This rule has been proven as a foundation of distributed database systems. Rule 12: Non-subversion rule This rule states that if a system has an interface that provides access to low level records, this interface then must not be able to subvert the system and bypass security and integrity constraints.