























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
rdbms lecture notes for final year
Typology: Lecture notes
1 / 31
This page cannot be seen from the preview
Don't miss anything!
























An Overview 2.1 PERSONAL DATABASES: Personal database management systems, such as Microsoft Access and Visual Fox Pro,are usually stored on user's desktop computer system or a client computer. These database packages are developed primarily for single- user applications. A server is a computer that accepts and services requestsfrom other computers,such as client computers. A server's resourcescould include the server's hard-diskdrive space,application programs on a server's hard-disk drivespace,application programs on a server's hard drive,data storedon the server's drive,or printers. A network is an infrastructure of hardware and software that enables computers to communicate with each other. i) Demand On Client and Network: If the client requires a small piece of data from the server’s large database, the server has to transmit the entire database to the client over the network. The client computer hardware must handle heavy demand, and the network must sustain heavy traffic in both directions. In network environment, the system response to various client requests depends on the speed of the network and the amount of traffic over it. ii) Table Locking: The personal database system assumes that no two transactions will happen at the same time on one table, which is known as optimistic locking. The tables are not locked by the database system. If one agent sells a seat for a basketball game and another agent tries to sell the same seat at the same time, the data base system will notify the second agent about the update on the table after his read but it will go ahead and let the second agent sell the seat anyway. iii) Client Failure: When a client is performing record insertions, deletions, or updates, those records are locked by that client and are not available to the other clients. If the client with all the record locks fails because of software or hardware malfunction or a power outage, the locked records stay locked. The database can get corrupted and needs to be repaired. To repair the database, all user have to log off during the repair.
If the database is not repairable, data can restored from the last backup, but the transactions since the last backup are lost and have to be reentered. iv) Transaction Processing: Personal databases, such as Microsoft access, do not have file- based transaction logging. Instead, transactions are logged in the client’s memory. If the client fails in the middle of a batch of transactions, some transactions are written to the database and same are not. The transaction log is lost, because it is not stored in a file. If a client writes a check to transfer money from a savings account to a checking account, the first transaction debits money from the savings account. 2.2 CLIENT/SERVER DATABASES: Client/Server databases, such as Oracle, run the DBMS as a process on the server and run a client database application on each other. The client application sends a request for data over the network to the server. i) Demand On Client and Network: The client does not store any database on its local drive;it receives only the requested data from the server. Data processing is performed on the server’s side. The demand at the client’s end is minimal. The clients request data from the server, and only requested data are send back via the network , which result in less traffic ii) Table Locking: In a client/server system, such as Oracle, when an agent reads a table to sell a seat for a basketball game, for example, it is locked totally or partly by the DBMS.
ANSI and ISO Structured Query Language is a forth- generation, high-level, nonprocedural language. The SQL language uses English-like commands such as C, COBOL, or Visual Basic, which are procedural. Oracle9i uses the following types of SQL statements for command-line queries to communicate with the Oracle server from any tool or application:
2.7.1 SQL*plus file-related commands: COMMAND DESCRIPTION GET filename [.ext] START filename [.ext] @filename EDIT EDIT [filename [.ext] ] SAVE filename [.ext] REPLACE | Writers previously saved file to the buffer. The default extension is SQL. Writes SQL statements, not SQL plus commands. Runs a previously saved command from file. Same as START. Invokes the default editor (e.g., Note pad), and saves buffer contents in a file called afiedt.buf. Saves current buffer contents to a file with the option to replace or append. APPEND SPOOL [filename [.ext] |OFF Stores query results in a file.OFF closes the file, and OUT sends the file to the SQL SQLplus 1.A nonprocedurallanguage to communicate with the oracle server.
Buffer Formatted Report SQL*plus Server
Exit system printer. Leaves SQLplus environment. Commits current transaction 2.7.2 SQLplus editing commands: COMMAND DESCRIPTION APPEND text CHANGE / old / new CHANGE /text / CLEAR BUFFER DEL DEL n DEL m n INPUT INPUT text LIST LIST n LIST m n RUN N n text 0 text CLEAR SCREEN Adds text to the end of the current line. Changes old text to new text in the current line. Deletes text from the current line. Deletes all lines from the SQL statement. Deletes current line. Deletes line n. Deletes line m through n. Inserts an indefinite number of lines. Inserts a line of text. Lists all lines from the SQL buffer. Lists line n. Lists line m through n. Displays and runs an SQL statement in the buffer. Makes line N current. Replaces line n with text. Inserts a line before line 1. Clears screen. 2.8 ORACLE ERRORS AND ONLINE HELP: If you make a syntax error, Oracle will display an error message showing the line number and the error location on that line. Some errors are easy to find; some are not. To fix an error, always start at the line where the error is shown, but keep in mind that the error might not be on that line.
The SQLplus worksheet is another environment available with Oracle’s Enterprise Manager. The SQLplus worksheet enables you to enter, edit, and execute SQLplus code.You can also run client-side scripts. START | [All] programs | Oracle – Orahome92 | Application Development | SQLplus Worksheet An enterprise Manager login screen is then displayed. The user logs in with username, password, a host string, just like logging into SQLplus. On a successful login, the leftside, a tool bar is displayed with connection, execute, command history, previous command, next command, and help icons from top to bottom, respectively. The SQLplus Worksheet screen has two horizontal halves. The user save input and output in separate files with the FILE menu and its options Save Input As… and Save Output As…, respectively. The input is stored in a file with the default extension. sql , and output is stored with the default extension .txt.
2.11 iSQLPlus: The third environment is web based and is called iSQLplus. To access it through a web browser, enter a URL as follows: http://machinename.domainname:port/isqlplus In this URL, machinename is your machine, but port number is not required in all versions.
A column allows NULL values and to specify if a column should have unique values only. A table and column names can be up to 30 characters long. In naming tables and columns, letters, numbers and special characters- $,_,# are allowed. It must begin with a letter and it is not case sensitive. Spaces and hyphens are not allowed in a table or column name. An Oracle server-reserved word cannot be used as a table or column name. Table name must be unique in a schema or user account. Valid Names Invalid Names STUDENT STUDENT_COURSE_REGISTRATION_TAB LE(more than 30 characters long) MAJOR_CODE MAJOR CODE (spaces not allowed) X CREATE (reserved word not allowed) PROJECT2000 PROJECT****2000 (special character * not allowed) STUDENT#REG#TA BLE #STUDENT (must start with a letter) 2.13 DATA TYPES A table is created each column in the table is assigned a data type. A data type specifies the type of data that will be stored in that column Data type also help to optimize storage space i)Varchar The VARCHAR2 type is a character data type to store variable- length alphanumeric data in a column. The default and minimum size is one character. The maximum allowable size is 4000 character in oracle9i. The size is specified within parentheses. Ex: VARCHAR2(20) If the data are smaller than the specified size. Only the data value is stored. And trailing spaces are not added to the value. If a value longer than the specified size is entered,however,an error is generated. The VARCHAR2 data type can also take CHAR or BYTE parameters. ii) Char The CHAR type is a character data type to store fixed-length alphanumeric data in a column.
The default and minimum size is one character. The maximum allowable size is 2000 character. The CHAR data type uses the storage more efficiently and processes data faster than the VARCHAR2 type. The CHAR data type can also take CHAR or BYTE parameter. Ex: PHONE, SOCIAL_SECURITY_NUMBER or MIDDLE_INITIAL columns iii) Number The NUMBER data type is used to store negative positive integer, fixed-decimal, and floating-point numbers. The NUMBER data type is used for any column that is going to be employed in mathematical calculations Ex: SALARY, COMMISSION, or PRICE When a number type is used for a column,its precision and scale can be specified. Precision is the total number of significant digits in the number, both to the left and to the right of the decimal point. The decimal point is not counted in specifying the precision. Range from 1 to 38. Scale is the total number of digits to the right of the decimal point. Range from -84 to 127. iv) Integer: An integer is a whole number without any decimal part. To define a column with integer values. Only the scale size is provided. For example to store the Employee Id 111, 112, 123 the data type for it would be NUMBER(3). v) Fixed-point: A fixed-point decimal number has a specific number of digits to the right of the decimal point. The price column has values in dollars and cents, which requires two decimal places. For example, the values like 2.95, 24.99 it is defined as NUMBER(4,2). vi) Floating-point: Floating-point decimal number has a variable number of decimal places. The decimal point may appear after any number of digits and it may not appear at all. To define such a column, do not specify the scale or precision along with the NUMBER type. For example, TAXRATE, INTEREST_RATE. vii) Date The DATE data type is used for storing date and time values.
Constraints enforce rules on tables. An oracle table can be created with the column names, data types and column sizes which are sufficient to populate them with actual data. The constraints help you to make your database with integrity. Whenever a row / record is inserted, updated or deleted from the table, a constraint must be satisfied for the operation to succeed. A table cannot be deleted if there are dependencies from other tables in the form of foreign keys. 2.14.1 Type of constraints