Sie sind auf Seite 1von 19

July 2011 Master of Computer Application (MCA) Semester 2 MC0066 OOPS using C++ 4 Credits

(Book ID: B0681 & B0715) Assignment Set 1 (40 Marks)

1.Write a program in C++ for matrix multiplication. The program should accept the dimensions of both the matrices to be multiplied and check for compatibility with appropriate messages and give the output. A:
#include<stdio.h> #include<conio.h> #include<malloc.h> void main() { int row_size1,col_size1,row_size2,col_size2; int **A,**B,**C; int i,j,e; printf("Enter the number of rows and columns in the first matrix:"); scanf("%d %d",&row_size1,&col_size1); printf("Enter the number of rows and columns in the second matrix:"); scanf("%d %d",&row_size2,&col_size2); A=(int**)malloc(row_size1*sizeof(int*)); for(i=0;i<col_size1;i++) { A[i]=(int*)malloc(col_size1*sizeof(int)); } B=(int**)malloc(row_size2*sizeof(int*)); for(i=0;i<col_size2;i++) { B[i]=(int*)malloc(col_size2*sizeof(int)); } C=(int**)malloc(row_size1*sizeof(int*)); for(i=0;i<col_size2;i++) { C[i]=(int*)malloc(col_size2*sizeof(int)); } if(col_size1!=row_size2) { printf("The matrices are not conformable "); }

else { printf("Enter the elements of the first matrix:"); for(i=0;i<row_size1;i++) for(j=0;j<col_size1;j++) scanf("%d",&A[i][j]); printf("Enter the elements of the second matrix:"); for(i=0;i<row_size2;i++) for(j=0;j<col_size2;j++) scanf("%d",&B[i][j]); for(i=0;i<row_size1;i++) { for(j=0;i<col_size2;j++) { C[i][j]=0; for(e=0;e<row_size2;e++) { C[i][j]=C[i][j]+(A[i][e]*B[e][j]); } } } printf("The required matrix is"); for(i=0;i<row_size1;i++) { for(j=0;j<col_size2;j++) printf("%d ",C[i][j]); printf("\n"); } }

2.Write a program to check whether a string is a palindrome or not. Please note that palindrome is one which remains the same if you reverse the characters in the string. For example MADAM. A:
#include <iostream> #include <string> using namespace std; int main() { char str[100]; cout << "Enter word :"; cin >> str; int x = strlen(str)-1; for(int i = 0; i <= x; i++)

{ if (str[i] == str[x-i]) { continue; } else { cout<<"Not a palidrome"<<endl; return 0; } } cout << "Indeed Palidrome"<<endl; return 0; }

3.What is structure in C++? Define a structure named product with elements productcode, description, unitprice and qtyinhand. Write a C++ program that implements the structure and enables to store atleast 100 product data.

A : A structure is a collection of variables under a single name. Variables can be of any type: int,
float, char etc. The main difference between structure and array is that arrays are collections of the same data type and structure is a collection of variables under a single name. Declaring a Structure: The structure is declared by using the keyword struct followed by structure name, also called a tag. Then the structure members (variables) are defined with their type and variable names inside the open and close braces "{"and "}". Finally, the closed braces end with a semicolon denoted as ";" following the statement. The above structure declaration is also called a Structure Specifier. #include <iostream>

int main() {

struct students { char name[10]; //name of student int SSN; // social security number char cardtype[10]; float balance; } for ( i = 0; i <= 10; i++ ) { std::cout << "Enter student name\n"; std::cin >> name[ i ]; std::cout << "Enter social security number\n"; std::cin >> SSN;

std::cout << "Enter card type\n"; std::cin >> cardtype[ i ]; }

4. What is the purpose of exception handling? How do you infer from the phrase, Throwing an exception?

A : Exception handling is a programming language construct or computer hardware mechanism


designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution. Programming languages differ considerably in their support for exception handling (as distinct from error checking, which is normal program flow that codes for responses to contingencies such as unsuccessful termination of invoked operations). In some programming languages there are functions which cannot be safely called on invalid input data or functions which return values which cannot be distinguished from exceptions. For example, in C the atoi (ASCII to integer conversion) function may return 0 (zero) for any input that cannot be parsed into a valid value. In such languages, the programmer must either perform error checking (possibly through some auxiliary global variable such as C's errno) or input validation (perhaps using regular expressions) or both. The degree to which such explicit validation and error checking is necessary is in contrast to exception handling support provided by any given programming environment. Hardware exception handling differs somewhat from the support provided by software tools, but similar concepts and terminology are prevalent. In general, an exception is handled (resolved) by saving the current state of execution in a predefined place and switching the execution to a specific subroutine known as an exception handler. Depending on the situation, the handler may later resume the execution at the original location using the saved information. For example, a page fault will usually allow the program to be resumed, while a division by zero might not be resolvable transparently. From the processing point of view, hardware interrupts are similar to resume-able exceptions, though they are typically unrelated to the user's program flow. From the point of view of the author of a routine, raising an exception is a useful way to signal that a routine could not execute normally. For example, when an input argument is invalid (e.g. a zero denominator in division) or when a resource it relies on is unavailable (like a missing file, or a hard disk error). In systems without exceptions, routines would need to return some special error code. However, this is sometimes complicated by the semipredicate problem, in which users of the routine need to write extra code to distinguish normal return values from erroneous ones. One mechanism for raising an exception is known as a throw. The exception is said to be thrown. Execution is transferred to a "catch". In runtime engine environments such as Java or .NET, there exist tools that attach to the runtime engine and every time that an exception of interest occurs, they record debugging information that existed in memory at the time the exception was thrown (call stack and heap values). These tools are called automated exception handling or error interception tools and provide 'root-cause' information for exceptions. Contemporary applications face many design challenges when considering exception handling strategies. Particularly in modern enterprise level applications, exceptions must often cross process boundaries and machine boundaries. Part of designing a solid exception handling strategy is

recognizing when a process has failed to the point where it cannot be economically handled by the software portion of the process.

Throwing an Exception
If you encounter an exceptional situation in your code that is, one where you dont have enough information in the current context to decide what to do you can send information about the error into a larger context by creating an object containing that information and throwing it out of your current context. This is called throwing an exception. Heres what it looks like: throw myerror(something bad happened); myerror is an ordinary class, which takes a char* as its argument. You can use any type when you throw (including built-in types), but often youll use special types created just for throwing exceptions. The keyword throw causes a number of relatively magical things to happen. First it creates an object that isnt there under normal program execution, and of course the constructor is called for that object. Then the object is, in effect, returned from the function, even though that object type isnt normally what the function is designed to return. A simplistic way to think about exception handling is as an alternate return mechanism, although you get into trouble if you take the analogy too far you can also exit from ordinary scopes by throwing an exception. But a value is returned, and the function or scope exits. Any similarity to function returns ends there because where you return to is someplace completely different than for a normal function call. (You end up in an appropriate exception handler that may be miles away from where the exception was thrown.) In addition, only objects that were successfully created at the time of the exception are destroyed (unlike a normal function return that assumes all the objects in the scope must be destroyed). Of course, the exception object itself is also properly cleaned up at the appropriate point. In addition, you can throw as many different types of objects as you want. Typically, youll throw a different type for each different type of error. The idea is to store the information in the object and the type of object, so someone in the bigger context can figure out what to do with your exception.

(Book ID: B0681 & B0715) Assignment Set 2 (40 Marks) 1.Write a program which accepts a number from the user and generates prime numbers till that number A:
#include <stdio.h> Void main() { int no,counter,counter1,check; clrscr(); printf(<PRIME NO. SERIES>); printf(\n\n\n\t\t\tINPUT THE VALUE OF N: ); scanf(%d,&no); printf(\n\nTHE PRIME NO. SERIES B/W 1 TO %d : \n\n,no); for(counter = 1; counter <= no; counter++) { check = 0; //THIS LOOP WILL CHECK A NO TO BE PRIME NO. OR NOT. for(counter1 = counter-1; counter1 > 1 ; counter1) if(counter%counter1 == 0) { check++; // INCREMENT CHECK IF NO. IS NOT A PRIME NO. break; } if(check == 0) printf(%d\t,counter); } getch(); }

2.Implement a class stack which simulates the operations of the stack allowing LIFO operations. Also implement push and pop operations for the stack. A:
#include #include void push(int st[],int data,int &top); void disp(int st[],int &top); int pop(int st[],int &top); int flg=0; int top=-1,tos=-1; int st[50]; void push(int st[],int data,int &top) { if(top==50-1) flg=0; else {

flg=1; top++; st[top]=data; } } int pop(int st[],int &top) { int pe; if(top==-1) { pe=0; flg=0; } else { flg=1; pe=st[top]; top--; } return(pe);

} void disp(int st[],int &top) { int i; if(top==-1) { printf("\nStack is Empty"); } else { for(i=top;i>=0;i--) printf("\t%d",st[i]); } } void main() { int dt,opt; int q=0; clrscr(); printf("This Program Is Used to Perform PUSH & POP operations On Stack"); printf("\n\n\tMain Menu........."); printf("\n\n1.Push"); printf("\n\n2.Pop"); printf("\n\n3.Exit"); do { printf("\n\n\tEnter Your Choice 1-3:"); scanf("%d",&opt); switch(opt) { case 1: printf("\nEnter the Element to be Push:"); scanf("%d",&dt);

push(st,dt,tos); if(flg==1) { printf("\nAfter Inserting the Element, Stack is:\n\n"); disp(st,tos); if(tos==50-1)

printf("\nStack is Now Full"); }

else printf("\nStack Overflow Insertion Not Possible"); break; case 2: dt=pop(st,tos); if(flg==1) { printf("\n\tData Deleted From the Stack is:%d\n",dt); printf("\n\tAfter Deleting the Element from the stack is:\n\n"); disp(st,tos); } else printf("\nStack Empty,Deletio Not Possible:"); break; case 3: q=1; break; default:printf("\nWrong Choice Enter 1-3 Only"); } }while(q!=1); }

OUTPUT Main Menu......... 1.push 2.pop 3.exit Enter your choice 1-3:1 Enter the element to be push:4 After inserting the elements,stack is: 4 Enter your choice 1-3:1 Enter the element to be push:7 After inserting the elements,stack is: 74 Enter your choice 1-3:1 Enter the element to be push:4

3. What are allocators? Describe the sequence container adapters. A : Allocators are one of the most mysterious parts of the C++ Standard library. Allocators are rarely
used explicitly; the Standard doesn't make it clear when they should ever be used. Today's allocators are substantially different from those in the original STL proposal, and there were two other designs in between all of which relied on language features that, until recently, were available on few compilers. The Standard appears to make promises about allocator functionality with one hand and then take those promises away with the other. The most important fact about allocators is that they were intended for one purpose only: encapsulating the low-level details of STL containers' memory management. You shouldn't invoke allocator member functions in your own code, unless you're writing an STL container yourself. You shouldn't try to use allocators to implement operator new[]; that's not what they're for. If you aren't sure whether you need to use allocators, then you don't. An allocator is a class with member functions allocate and deallocate, the rough equivalents of malloc and free. It also has helper functions for manipulating the memory that it allocated and typedefs that describe how to refer to the memory names for pointer and reference types. If an STL container allocates all of its memory through a user-provided allocator (which the predefined STL containers all do; each of them has a template parameter that defaults tostd::allocator), you can control its memory management by providing your own allocator.

Sequence Adapters
The vector, list, and sequences cannot be built from each other without loss of efficiency. On the other hand, stacks queue can be elegantly and efficiently implemented using those three basic sequences. Therefore, stack and queue are defined not as separate containers, but as adaptors of basic containers. A container adapter provides a restricted interface to a container. In particular, adapters do not provide iterators; they are intended to be used only through their specialized interfaces. The techniques used to create a container adapter from a container are generally useful for nonintrusively adapting the interface of a class to the needs of its users.

4. Write about the following with the help of suitable programming examples: A) Throwing an Exception B) Catching an Exception A: A) Throwing an Exception
If you encounter an exceptional situation in your code that is, one where you dont have enough information in the current context to decide what to do you can send information about the error into a larger context by creating an object containing that information and throwing it out of your current context. This is called throwing an exception. Heres what it looks like: throw myerror(something bad happened); myerror is an ordinary class, which takes a char* as its argument. You can use any type when you throw (including built-in types), but often youll use special types created just for throwing exceptions. The keyword throw causes a number of relatively magical things to happen. First it creates an object that isnt there under normal program execution, and of course the

constructor is called for that object. Then the object is, in effect, returned from the function, even though that object type isnt normally what the function is designed to return. A simplistic way to think about exception handling is as an alternate return mechanism, although you get into trouble if you take the analogy too far you can also exit from ordinary scopes by throwing an exception. But a value is returned, and the function or scope exits. Any similarity to function returns ends there because where you return to is someplace completely different than for a normal function call. (You end up in an appropriate exception handler that may be miles away from where the exception was thrown.) In addition, only objects that were successfully created at the time of the exception are destroyed (unlike a normal function return that assumes all the objects in the scope must be destroyed). Of course, the exception object itself is also properly cleaned up at the appropriate point. In addition, you can throw as many different types of objects as you want. Typically, youll throw a different type for each different type of error. The idea is to store the information in the object and the type of object, so someone in the bigger context can figure out what to do with your exception.

B) Catching an Exception
To see how an exception is caught, you must first understand the concept of a guarded region. This is a section of code that might produce exceptions and is followed by the code to handle those exceptions.

The try block


If you are inside a method and you throw an exception (or another method that you call within this method throws an exception), that method will exit in the process of throwing. If you don't want a throw to exit the method, you can set up a special block within that method to capture the exception. This is called the try block because you "try" your various method calls there. The try block is an ordinary scope preceded by the keyword try. try { // Code that might generate exceptions } If you were checking for errors carefully in a programming language that didn't support exception handling, you'd have to surround every method call with setup and error-testing code, even if you call the same method several times. With exception handling, you put everything in a try block and capture all the exceptions in one place. This means your code is much easier to write and read because the goal of the code is not confused with the error checking.

July 2011 Master of Computer Application (MCA) Semester 2 MC0067 Database Management System (DBMS and Oracle 9i) 4 Credits (Book ID: B0716 & B0717)
Assignment Set 1 (40 Marks)
1. Write about:

A: Linear Search
Linear searching is a way to find if a certain element (number , string , etc. ) is in a specified array. The array can be in any order, or be completely jumbled and this search will find the element if it is there. If the element is found we can return the index where the element is located in the array. If the element is not found we can return -1. We can assume no array will ever have an negative number as an index. Our approach will be to check every element in the array to see if it is what we are looking for. We will use a loop to cycle through the array. Here goes:

int findElement(int yourArray[], int tobefound, int length)// method to find index of specified element { int notfound = -1; int counter; for( counter = 0; counter<length; counter++ ) { if(tobefound == yourArray[counter])//check if we found the number we are looking for { return counter; } }//end for loop //if we got this far we must not have found the number return notfound; }

Collision Chain
In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). Thus, a hash table implements an associate array. The hash function is used to transform the key into the index (the hash) of an array element (the slot or bucket )where the corresponding value is to be sought. Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added tothe table after it is created). Instead, most hash table designs assume that hast collisionsdifferent keys that map to the same hash valuewill occur and must be accommodated in some way.

2. Write about:

Collision Chain
A:

Integrity Rules
These are the rules which a relational database follows in order to stay accurate and accessible.These rules govern which operations can be performed on the data and on the structure of thedatabase. There are three integrity rules defined for a relational databse,which are:-

Distinct Rows in a Table - this rule says that all the rows of a table should be distinct toavoid in ambiguity while accessing the rows of that table. Most of the modern databasemanagement systems can be configured to avoid duplicate rows.

Entity Integrity (APrimary Key or part of it cannot be null) - this rule says that 'null'is special value in a relational database and it doesn't mean blank or zero. It means theunavailability of data and hence a 'null' primary key would not be a complete identifier.This integrity rule is also termed as entity integirty.

Referential Integrity - this rule says that if a foreign key is defined on a table then avalue matching that foreign key value must exist as th e primary key of a row in someother table. The following are the integrity rules to be satisfied by any relation. No Component of the Primary Key can be null. The Database must not contain any unmatched Foreign Key values. This is called thereferential integrity rule. Unlike the case of Primary Keys, there is no integrity rule saying that no component of the foreign key can be null.

Relational Operators with examples for each


In the relational model, the database objects seen so far have specific names :Name Meaning Relation Table Tuple Record(Row) Attribute Field(Column)Cardinality Number of Records(Rows)Degree(or Arity) Number of Fields(Columns)View Query/ Answer tableOn these objects, a set of operators (relational operators) is provided to manipulatethem:1. Restrict2. Project3. Union4. Difference5. Product 6. Intersection7. Join8. Divide Restrict : Restrict simply extract records from a table it is also known as Select, but not the same SELECT as defined in SQL .Project :Project selects zero or more fields from a table and generates a new table that contains all of the records and only the selected fields (with no duplications). Union :Union creates a new table by adding the records of one table to another tables, must be compatible: have the same number of fields and each of the field pairs has to have values in the same domain. Difference :The difference of two tables is a third table which contains the records

which appear in the first BUT NOT in the second. Product .The product of two tables is a third which contains all of the records in the first one added to each of the records in the second Intersection. The intersection of two tables is a third tables which contains the records which are common to both Join. The join of two tables is a third which contains all of the records in the first and the second which are related. Divide. Dividing a table by another table gives all the records in the first which have values in their fields matching ALL the records in the second. The eight relational algebra operators are. 1.SELECT To retrieve specific tuples/rows from a relation. 2.PROJECT To retrieve specific attributes/columns from a relation. 3.PRODUCT To obtain all possible combination of tuples from two relations. 4.UNION To retrieve tuples appearing in either or both the relations participating in the UNION. 5.INTERSECT To retrieve tuples appearing in both the relations participating in the INTERSECT. 6.DIFFERENCE To retrieve tuples appearing in the first relation participating in the DIFFERENCE but not the second. 7.JOIN To retrieve combinations of tuples in two relations based on a common field in both the relations.

Linear Search
Linear searching is a way to find if a certain element (number , string , etc. ) is in a specified array. The array can be in any order, or be completely jumbled and this search will find the element if it is there. If the element is found we can return the index where the element is located in the array. If the element is not found we can return -1. We can assume no array will ever have an negative number as an index. Our approach will be to check every element in the array to see if it is what we are looking for. We will use a loop to cycle through the array. Here goes:

int findElement(int yourArray[], int tobefound, int length)// method to find index of specified element { int notfound = -1; int counter; for( counter = 0; counter<length; counter++ ) { if(tobefound == yourArray[counter])//check if we found the number we are looking for { return counter; } }//end for loop //if we got this far we must not have found the number return notfound; }

Collision Chain
In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). Thus, a hash table implements an associate array. The hash function is used to transform the key into the index (the hash) of an array

element (the slot or bucket )where the corresponding value is to be sought. Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added tothe table after it is created). Instead, most hash table designs assume that hast collisionsdifferent keys that map to the same hash valuewill occur and must be accommodated in some way.

3. Discuss the correspondences between the ER model constructs and the relational model constructs. Show how each ER model construct can be mapped to the relational model, and discuss any alternative mappings A : There is almost a one-to-one correspondence between the ER constructs and the relational ones.
The two major distinctions are: In a relational schema, relationships are represented implicitly through primary and foreign keys of participating entities. In a relational schema, columns of relations cannot be multivalued or composite. Composite attributes are replaced with their simple component ones, and multivalued attributes are stored in a separate relation. ER Construct entity 1:1 or 1:N relationship M:N relationship n-ary relationship type simple attribute composite attribute multivalued attribute value set key attribute Mapping Algorithm table Foreign key (or a table to capture the relationship) "relationship" table and 2 foreign keys "relationship" table and 'n' foreign keys column set of simple component columns table and foreign key domain primary (or secondary) key Relational Construct

We can translate an ER schema to a relational schema by following a nine-step algorithm based on the one given in Elmasri and Navathe 1994. The algorithm attempts to minimize the need for joins and NULL values when defining relations (Steps 2, 4, and 5). For each strong entity type E Create a new table. Include as its columns, all the simple attributes and simple components of the composite attributes of E. Identify the primary key and the alternate keys. For each weak entity W that is associated with only one 1:1 identifying owner relationship Identify the table T of the owner entity type. Include as columns of T, all the simple attributes and simple components of the composite attributes of W. For each weak entity W that is associated with a 1:N or M:N identifying relationship, or participates in more than one relationship

Create a new table T. Include as its columns, all the simple attributes and simple components of the composite attributes of W. Form the primary key of T as follows: In the case of a 1:N owner relationship, by including as a foreign key in T, the primary key of the owner entity. The primary key of T is the combination of W's partial key and the foreign key. In the case of an M:N owner relationship, by creating a new column that will hold unique values. (In this case, the association between the weak entity and its owner entity will be specified in Step 6.) For each binary 1:1 relationship type R Identify the tables S and T of the participating entity types. Choose S (preferably the one with total participation). Include as foreign key in S, the primary key of T. Include as Columns of S, all the simple attributes and simple components of the composite attributes of R. For each binary 1:N relationship type R Identify the table S (at the N-side) and T of the participating entities. Include as a foreign key in S, the primary key of T. Include as columns of S, all the simple attributes and simple components of composite attributes of R. For each N-ary relationship (including binary N:M relationship) type R Create a new table T. Include as columns of T, all the simple attributes and simple components of composite attributes of R. Include as foreign keys, the primary keys of the participating (strong or weak) entity types. Specify as the primary key of T, the list of foreign keys. For each multivalued attribute A Create a new table T. Include as columns of T, the simple attribute or simple components of the attribute A. Include as foreign key, the primary key of the entity or relationship type that has A. Specify as the primary key of T, the foreign key and the columns corresponding to A. For each specialization with disjoint subclasses Create a new table Ti for each subclass Si. Include as columns of Ti, the simple attributes and simple component attributes of the superclass. Include as columns of Ti, the simple attributes and simple component attributes specific to Si.

Identify the primary key. For each specialization with overlapping subclasses Create a new table O for the superclass. Include as columns of O, the simple attributes and the simple component attributes of the superclass. Identify its primary key and alternate keys. Create a new table Ti for each subclass Si. Include as columns of Ti, the simple attributes and simple component attributes specific to Si. Include as a foreign key in Ti (to be part of the primary key of Ti), the primary key of O.

4. Define the following terms: disk, disk pack, track, block, cylinder, sector, interblock gap, read/write head. A: Disk:
Disk s are used for storing large amounts of data. The most basic unit of data on the disk is a single bit of information. By magnetizing a area on disk in certain ways, one can make it represent a bit value of either 0 or 1. To code information, bits are grouped into bytes. Byte sizes are typically 4 to 8 bits, depending on the computer and the device. We assume that one character is stored in a single byte, and we use the terms byte and character interchangeably. The capacity of a disk is the number of bytes it can store, which is usually very large. Small floppy disks used with microcomputers typically hold from 400k bytes to 1.5 Mbytes; hard disks for micros typically hold from several hundred Mbytes up to a few G bytes. Whatever their capacity, disks are all made of magnetic material shaped as a thin circular disk and protected by a plastic or acrylic cover. A disk is single-sided if it stores information on only one of its surface and double-sided if both surfaces are used.

Disk Packs:
To increase storage capacity, disks are assembled into a disk pack, which may include many disks and hence many surfaces. A Diskpack is a layered grouping of hard disk platters (circular,rigid discs coated with a magnetic data storage surface). Disk pack is the core component of a hard disk drive. In modern hard disks, the disk pack is permanently sealed inside the drive. In many early hard disks,the disk pack was a removable unit, and would be supplied with a protective canister featuring a lifting handle.

Track and cylinder:


The (circular) area on a disk platter which can be accessed without moving the access arm of the drive is called track. Information is stored on a disk surface in concentric circles of small width, for each having a distinct diameter. Each circle is called a track. For disk packs, the tracks with the same diameter on the various surfaces are called cylinder because of the shape they would form if connected in space. The set of tracks of a disk drive which can be accessed without changing the position of the access arm are called cylinder. The number of tracks on a disk range from a few hundred to a few thousand, and the capacity of each track typically range from tens of Kbytes to 150 Kbytes.

Sector:
A fixed size physical data block on a disk drive. A track usually contains a large amount of information; it is divided into smaller blocks or sectors. The division of a track into sectors is hard-coded on the disk surface and cannot be changed. One type of sector organization calls a portion of a track that subtends a fixed angle at the center as a sector. Several other sector organizations are possible, one of which is to have the sectors subtend smaller angles at the center as one moves away, thus maintaining a uniform density of recording.

Block and Interblock Gaps:


A physical data record, separated on the medium from other blocks by inter-block gaps is called block. The division of a track into equal sized disk blocks is set by the operating system during disk formatting. Block size is fixed during initialization and cannot be changed dynamically.Typical disk block sizes range from 512 to 4096 bytes. A disk with hard coded sectors often hasthe sectors subdivided into blocks during initialization .An area between data blocks which contains no data and which separates the blocks is called interblock gap. Blocks are separated by fixed size interblock gaps, which include specially coded control information written during disk initialization. This information is used to determine which block on the track follows each interblock gap.

Read/write Head:
A tape drive is required to read the data from or to write the data to a tape reel. Usually, each group of bits that forms a byte is stored across the tape, and the bytes themselves are stored consecutively on the tape. A read/write head is used to read or write data on tape. Data records on tape are also stored in blocks-although the blocks may be substantially larger than those for disks, and interblock gaps are also quite large. With typical tape densities of 1600 to 6250 bytes per inch, a typical interblock gap of 0.6 inches corresponds to 960 to 3750 bytes of wasted storage space

(DBMS and Oracle 9i) 4 Credits


(Book ID: B0716 & B0717) Assignment Set 2 (40 Marks)

1. Explain the purpose of Data Modeling. What are the basic constructs of E-R Diagrams? A:

1.Data modeling
in is the process of creating a data model by applying formal data model descriptions using data modeling techniques. Data modeling is the act of exploring data-oriented structures. Like other modeling artifacts data models can be used for a variety of purposes, from high-level conceptual models to physical data models. Data modeling is the formalization and documentation of existing processes and events that occur during application software design and development. Data modeling techniques and tools capture and translate complex system designs into easily understood representations of the dataflows and processes, creating a blueprint for construction and/or re-engineering.

Basic Constructs of E-R Modeling:


The ER model views the real world as a construct of entities and association between entities.The basic constructs of ER modeling are entities, attributes, and relationships.Entity:An entity may be defined as a thing which is recognized as being capable of an independent existence and which can be uniquely identified. An entity is an abstraction from the complexities of some domain. When we speak of an entity we normally speak of some aspect of the real world which can be distinguished from other aspects of the real world. An entity may be a physical object such as a house or a car, an event such as a house sale or a car service, or a concept such as a customer transaction or order. Although the term entity is the one most commonly used, following Chen we should really distinguish between an entity and an entity-type. An entity-type is a category. An entity, strictly speaking, is an instance of a given entity-type. There are usually many instances of an entity-type. Because the term entity-type is somewhat cumbersome, most people tend to use the term entity as a synonym for this term. Entities can be thought of as nouns. Examples: a computer, an employee, a song, a mathematical theorem.

Relationship:
A relationship captures how two or more entities are related to one another. Relationships can be thought of as verbs, linking two or more nouns. Examples: an owns relationship between a company and a computer, a supervises relationship between an employee and a department, a performs relationship between an artist and a song, a proved relationship between a mathematician and a theorem.

Attributes:
Entities and relationships can both have attributes. Examples: an employee entity might have a Social Security Number (SSN) attribute; the proved relationship may have a date attribute.

2. Write about:

A:

Types of Discretionary Privileges:


The concept of an authorization identifier is used to refer, to a user account. The DBMS must provide selective access to each relation in the database based on specific accounts. There are two levels for assigning privileges to use use the database system: The account level : At this level, the DBA specifies the particular privileges that each account holds independently of the relations in the database. The relation (or table level ):At this level, the DBA can control the privilege to access each individual relation or view in the database.The privileges at the account level apply to the capabilities provided to the account itself and can include the CREATE SCHEMA or CREATE TABLE privilege, to create a schema or base relation; the CREATE VIEW privilege; the ALTER privilege, to apply schema changes such adding or removing attributes from relations; the DROP privilege, to delete relations or views; the MODIFY privilege, to insert, delete, or update tuples; and the SELECT privilege, to retrieve information from the database by using a SELECT query.The second level of privileges applies to the relation level, whether they are base relations or virtual (view) relations.The granting and revoking of privileges generally follow an authorization model for discretionary privileges known as the access matrix model, where the rows of a matrix Mre presents subjects(users, accounts, programs) and the columns represent objects(relations,records, columns, views, operations). Each position M(i,j) in the matrix represents the types of privileges (read, write, update) that subject i holds on object j.To control the granting and revoking of relation privileges, each relation R in a database is assigned and owner account, which is typically the account that was used when the relation was created in the first place. The owner of a relation is given all privileges on that relation. The

Das könnte Ihnen auch gefallen