Sie sind auf Seite 1von 16

PANKAJ KUMAR ISRANI ADBMS LAB ASSIGNMENT Mtech CS

i) A table with about 5 rows and 7 columns, containing integer numbers each, needs to be stored. The size of the table will hardly grow in the future. Sol- Heap File Reason- The data storage that is used to store this table (5 rows and 7 columns) should be Heap file .
In heap file when we store data then no need of sorting of data,we insert data

as it comes.
The data record are sorted using data record identifier field ( each data record have an uniqe identifier ). This make able to quickly find a data record in file knowing its identifier. The root data record is given by heap file header. The basic services provided by Heap file are: create a data record giving the data size needed and return its identifier. Delete a data record giving its identifier. read a data record giving identifier and returning associated data.

write a data record giving identifier and associated data.

ii) A telephone book needs to be stored on a CD-ROM Database. It contains the addresses of all people in the Netherlands. For queries the first and last name of the person or only the last name of the person needs to be entered and the system should give a quick response. Selections by address and telephone number are not allowed. Sol- Clustered B+ tree index

ReasonIn B+ tree need of search key to sort the data.in this problem the search key is name of user.because it is mentioned that for queries the first and last name of the person or only the last name of the person needs to be entered. the clustered index dictates the physical storage order of the data in the table, a table can contain only one clustered index. we make a cluster of addresses of all people in the Netherlands by using the search key name.(by last name or first name). . iii) In a demographic database for the ministry of work, the job affiliation of all people of South-Holland should be recorded. Often the ministry will enter queries about jobs of people in a certain age range or income range. A clustered B+ tree index has already been created previously on the SOFI number of the people registered in the database. Suggest additional indexes for frequent queries! Sol-Unclustered B+ Tree REASON : i. Unclustered B+ Tree support over small range and for useful in frequent queries. ii. In this problem data should be sorted acc. to age. and here a range given. so we can`t use hash index. because we avoid hash index in range query. iii. clustered B+ tree is already given so we will use unclustered B+ tree.

iv) The biology department of the University of Leiden wants to collect information about observations of endangered animal and plant species in Leiden and its surrounding lakes, polders, and dunes. For each observation

GPS coordinates, name of the observer, and a date is recorded. A rough estimation says that there will be no more than 10 observations per species encountered. The total number of observations can be very high, however. Suggest an index that supports queries that find all observations for a specific species (identified by latin name)! Sol- Clustered Hash Index REASON : i. ii. It provides direct access to find all observation for a specific species . Clustered Hash index access the record with given key. There is a condition that find all observation for a specific species(identified by latin name). for each observation GPS coordinates, name of observer, and a date is recorded. So need to store data in sorted manner by using the search key. we can directly access that search. It also provides faster retrieval for queries and supports overflow.

iii. iv. v.

2. Which of the index types Clustered Hash Index, Clustered B+Tree Index, Unclustered B+ Tree,Heap File, Sorted file are suitable in the following scenarios. Justify your answer briefly! i) A university database contains a small table of faculty buildings with their address. The number of buildings is about 10 and cannot be assumed that the number of buildings will increase rapidly the next decades. Choose an appropriate file organization and/or index if there are often queries on the building names. Sol- Sorted file Reason- In this query the number of buildings are approx fixed. If we use Sorted File we can sort the name of the building with their address. It provides efficient searching.So faster queries performance once list is sorted.

ii) A huge database is build for trekking equipment. There is already a clustered index on the scan-code number of the products. How can queries that combine the product category with price intervals be supported by means of an index? Sol- ClusteredB+Tree Index Reason- A clustered B+ tree will allow us to answer range queries efficiently. Clustering alters the data block into a certain distinct order to match the index, resulting in the row data being stored in order. therefore, only one clustered index can be created on a given database table. clustered indices can greatly increase overall speed of retrieval, but usually only where the data is accessed sequentially in the same or reverse order of the clustered index or when a range of items is selected. iii) A large mineral database is build to collect information about the mining places for different sorts of rare gems and jewels. Though there are various types of gems and jewels (all indicated by a name) each one of them can be found only in a few (1-maximally 10) places. Often the name of a gem is the search key for a query. Sol- unclustered B+ tree . ReasonIn this problem a large mineral database is build to collect information about the mining places for different sorts of rare gems and jewels. Each one of them can be found only in a few places. search key is also gem for the query so need of sorting of search key in this case , and because find In few so need of sequential access of data by using search key.

iv) A list of all papers of a conference is stored on a DVD. For dataprotection reasons the only way to query the documents is by means of the document-id that is given in the hardcopy of the proceedings handed out to the members of the conference. The number of papers on the DVD is huge. SolReason-

3. Data Modeling for given database:

4. Create a database for storing images to be used as passwords. Each user is to be presented 10 images out which one will be selected by him as his password image. He is also required to specify a pass phrase and a text password. The user is to be presented with a login screen. On getting the username, 10 images are to be presented to user. He is to click on the correct image to get the dialogue box for pass phrase and password. Access is to be allowed if all the information matches.

Database :

Login Page

Public Class login Dim con As New ADODB.Connection Dim recInfo As New ADODB.Recordset Dim usr As String Dim pwd As String Dim FA As Integer = 0 Private Sub login_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing recInfo.Close() con.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If txtusr.Text.Trim = "" Then MessageBox.Show("You must Fill a UserName.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information) txtusr.Focus() Exit Sub End If Try recInfo.Filter = "Username = '" & txtusr.Text & "'" usr = recInfo.Fields("Username").Value pwd = recInfo.Fields("Password").Value GroupBox1.Visible = True GroupBox3.Visible = True Catch ex As Exception MsgBox("Username Doesn't Exist. Please Type Correct Username") Exit Sub

End Try End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click picimg.Image = PictureBox1.Image End Sub Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click picimg.Image = PictureBox2.Image End Sub Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click picimg.Image = PictureBox3.Image End Sub Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click picimg.Image = PictureBox4.Image End Sub Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click picimg.Image = PictureBox5.Image End Sub Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click picimg.Image = PictureBox6.Image End Sub Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click picimg.Image = PictureBox7.Image End Sub Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.Click picimg.Image = PictureBox8.Image End Sub Private Sub PictureBox9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click picimg.Image = PictureBox9.Image End Sub

Private Sub PictureBox10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox10.Click picimg.Image = PictureBox10.Image End Sub Private Sub picimg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picimg.Click Dim bmimg1, bmimg2 As Bitmap Dim bytImage() As Byte Try bytImage = recInfo.Fields("Photo").Value Dim ms As New System.IO.MemoryStream(bytImage) Dim bmImage As New Bitmap(ms) ms.Close() bmimg1 = bmImage Catch ex As Exception MsgBox(ex.ToString) End Try Dim bytImage1() As Byte Try Dim ms As New System.IO.MemoryStream Dim bmpImage As New Bitmap(picimg.Image) bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) bytImage1 = ms.ToArray() bmimg2 = bmpImage ms.Close() Catch ex As Exception MsgBox(ex.ToString) End Try If bmimg1.Width = bmimg2.Width And bmimg1.Height = bmimg2.Height Then GroupBox2.Visible = True Button2.Visible = True Else MessageBox.Show("You Selected wrong image.", "Wrong Input", MessageBoxButtons.OK, MessageBoxIcon.Information) FA = FA + 1 If (FA = 3) Then GroupBox1.Visible = False GroupBox3.Visible = False GroupBox4.Visible = False recInfo.Requery()

MessageBox.Show("Your Account has been locked.Please Close the Form.", "More Unsuccessfull Attempts ::", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Exit Sub End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click pwd = recInfo.Fields("Password").Value If txtpass.Text = pwd Then lbllogin.Text = "you successfully login" lbllogin.Visible = True Else MessageBox.Show("You entered wrong Password.", "Wrong Input", MessageBoxButtons.OK, MessageBoxIcon.Information) FA = FA + 1 If (FA = 3) Then GroupBox1.Visible = False GroupBox2.Visible = False GroupBox3.Visible = False GroupBox4.Visible = False recInfo.Requery() MessageBox.Show("Your Account has been locked.Please Close the Form.", "More Unsuccessfull Attempts ::", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Exit Sub End If recInfo.Requery() End Sub Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con = New ADODB.Connection con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\pps.mdb") recInfo = New ADODB.Recordset recInfo.Open("SELECT * FROM sec", con, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) End Sub End Class

NEW USER

Public Class NEWUSER Dim con As New ADODB.Connection Dim recInfo As New ADODB.Recordset Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click con = New ADODB.Connection con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\pps.mdb") recInfo = New ADODB.Recordset recInfo.Open("SELECT * FROM sec", con, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) If txtusr.Text.Trim = "" Then MessageBox.Show("You must Fill a UserName.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information) txtusr.Focus() Exit Sub End If If txtpass.Text.Trim = "" Then MessageBox.Show("You must Fill a Password.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information) txtpass.Focus() Exit Sub

End If recInfo.AddNew() recInfo.Fields("Username").Value = CStr(txtusr.Text) recInfo.Fields("Password").Value = txtpass.Text recInfo.Fields("FailedPhAttempt").Value = CInt("0") recInfo.Fields("FailedPsAttempt").Value = CInt("0") Dim bytImage() As Byte Try Dim ms As New System.IO.MemoryStream Dim bmpImage As New Bitmap(picimg.Image) bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) bytImage = ms.ToArray() ms.Close() Catch ex As Exception MsgBox(ex.ToString) End Try recInfo.Fields("Photo").Value = bytImage recInfo.Update() MessageBox.Show("Your data has been saved successfully.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information) recInfo.Close() con.Close() End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click picimg.Image = PictureBox1.Image End Sub Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click picimg.Image = PictureBox2.Image End Sub Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click picimg.Image = PictureBox3.Image End Sub

Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click picimg.Image = PictureBox4.Image End Sub Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click picimg.Image = PictureBox5.Image End Sub Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click picimg.Image = PictureBox6.Image End Sub Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click picimg.Image = PictureBox7.Image End Sub Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.Click picimg.Image = PictureBox8.Image End Sub Private Sub PictureBox9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click picimg.Image = PictureBox9.Image End Sub Private Sub PictureBox10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox10.Click picimg.Image = PictureBox10.Image End Sub End Class

Das könnte Ihnen auch gefallen