Lesson 02: Creating Database
Save database file Create table by using wizard Differentiate field, record and table Define primary key Insert data in the table Save table Find record from table At the end of this lesson, students should be able to:
For example, students profiles table as shown below. (Figure 1) Creating Table record 2 Field 1 (numbers) Field 1 (name) Field 1 (address) Field 1 (icno) Figure 1
1.Open MS Access 2003 software Steps Creating Table 2.Click File, click Open, find students profiles database file then click Open button. (refer Figure 2) Figure 2
3.Database window students profile: Database will appeared as shown below (Figure 3) then click New button at database windows toolbar. The dialog box in Figure 4 will appear. Figure 3
4.Click Design View, then click OK to get Datasheet view as shown at Figure 5. Figure 4 Figure 5 Design View
5.At Field Name column, type in numbers and at Data type column, change value Text to Number. (refer Figure 6) Figure 6 Click this button to view the list of data type, then click number
6.There are 10 types of data as stated in the table below: Types DataFunction TextYou may type in any alphabetical/numerical data that you desire-up to a maximum of 255 characters. As indicated, this is a text field, so you can't do mathematical calculations. Examples of Text data are: names, addresses, stock numbers, room numbers, zip codes, etc
MemoThis field is for lots of text. You can have up to 32,000 characters. NumberThis field is for numbers where you want to add, subtract, multiply, divide, average, and do numerical calculations. This field can be a very large size, so when we get to Field Properties, we'll talk about "sizing" this field so it doesn't take up too much "space" in storage.
Types DataFunction Date/TimeDates and Times. You may format this later, as you may desire. CurrencyDollar ($). You may format this later, as you may desire. For example Ringgit Malaysia (RM) AutoNumberThis field is an "automatic" counter that assigns a number each time you put data into a new field.
7.There are 10 types of data as stated in the table below: Types DataFunction OLE ObjectThis means "Object Link Embedding" which indicates you can insert a graphic, picture, sound, etc. Pretty neat to put a photograph in a personnel record or a picture of an inventory item in the stock record (advanced stuff).
HyperlinkA hyperlink is a pointer from one object to another. The destination is frequently another Web page, but it can also be a picture, an e- mail address, a file (such as a multimedia file or Microsoft Office document), or a program. The hyperlink itself can be displayed as text or as a picture. Lookup Wizard This wizard creates a lookup column, which displays a list of values you can choose from.
8.Insert data in the Field Name, Data Types for each fields as displays (Figure 7). Students can move to the next column by press “Tab key”. Figure 7 Place the cursor at address Change Field Size value to 100 Figure 8
9.Click numbers at field name column, click at Edit menu bar, then click 10. Primary Key or icon Primary Key. Shown at Figure 9. Primary key icon Figure 9 close icon
11. Click Close icon as shown at figure 8 to close the creating table session. Then dialog box in figure 9 displayed. 12.Click Yes. Dialog box Save As in figure 10 displayed Figure 10 Figure 11 Key in table name here
13.Type students profile at Table Name and then click OK at dialog box as shown in figure 10. Now you had finished creating one table named “students pofile:database” as shown below. (Figure 12) Figure 12 students profile table created
1.Click at Students Profile table then click open at database window toolbar. (Figure 13) Inserting Data in the Table Figure 13
2.Datasheet view Students Profile : Table as shown in Figure 14 displayed 3.Key in data at the students profile datasheet Figure 14
4.At the first row, type number ‘1’ at numbers column. Then, Type name Abdul Rahman b. Idris at name column. Next, type address and ic number at address and icno column. Figure 15
5.Insert all data in the table by repeating the same process above. As a result, students will get the table below 6.Click icon save to saving file. Students Profile table now contained five records 7.Click icon close to close the inserting data session Figure 16
Add Records 1.Open Microsoft Access Click Open an Existing Database, then click file students profile and click OK. 3.In the database window, double click students profile in the Tables pane to open the table in Datasheet view, as shown in figure 17.
4.To add new record, click on icon New Record that can be seen at database toolbar or at the bottom of datasheet window. (refer Figure 17). Figure 17 Icon New record
5.Add five more record as below. (refer table 1) nameaddressicno Alias b MohamadNo. 5, Jalan Desa Kayang 3, Desa kayang, Kangar Mohd Shahid b Mohd Som No. 39, Taman Tapah, Jalan Pahang Tapah, Perak Noorul-Aini bt AmbakNo 15, Jalan Limau Kasturi, 4/4A Shah Alam, Selangor Noor Asiah bt ZakariaLot 2646, Kg Simpang Tiga, Bt 6 3/4, Gombak, Selangor Fasitah bt. MansorNo. 36, Jln. Melati, Tmn. Mewah, Batu Gajah, Perak Table 1 6. Save record. 7.Close students profile : Table.
Add Fields Method 1: Add field after the last field. 1.Click Design button at database toolbar windows Students Profile: Database, to display all the fields. 2.Click field below icno (refer Figure 18)
3.Type in inside the Field Name and select text as the Data Type. Figure 18 4.Save the record
Add Fields Method 1: Add field after the last field. 1.Click Design button at database toolbar windows Students Profile: Database, to display all the fields. 2.Click field below icno (refer Figure 19)
Figure 19 3.Save the record
Method 2: Add new field in between the two fields 1.Click Design button at database toolbar windows Students Profile: Database, to display all the fields. 2.Click the address field ( the row will be highlight -refer Figure 20 )
3.Put cursor in between field name and field address. 4.Type in sex inside the blank Field Name and select text as the Data Type.(refer Figure 20) Figure 20
3.Put cursor in between field name and field address. 4.Type in sex inside the blank Field Name and select text as the Data Type.(refer Figure 20) 5.Save students profile. 6.Click to close students profile : Table.
1.Open Students Profile table. 2. To edit record, click inside the selected field. (sex and ) 3. Insert in all the record for sex field and field. (refer Table 2) Edit Record.
numbersnamesexaddress 1Abdul Rahman b. 2Johana bt. 3Faridah bt 4Rosnani bt. 5Hassan b. 6Alias b 7Mohd Shahid b Mohd 8Noorul-Aini bt 9Noor Asiah bt 10Fasitah bt. Table 2
3. Repeat step 2 above to add in 5 postcodes (see bold figure) inside the first five record. (Refer Table 3). Numbers NameSexAddress 1Abdul Rahman b. Idrismale 2304, Rumah Rumah Tasek Gelugor, Pulau Pinang 2 Johana bt. Muhammad sxsMMMuhammad female No 24, Jln 1, Taman Seri Sinar, Kulal Lumpur 3Faridah bt AbdullahFemale No 39, Jln Pinang Merah 11, Bandar Tengg, Johor 4Rosnani bt. SembokFemaleNo 1005, Kuala Terengganu, Terengganu 5 Hassan b. Wahid Choong Fook Keong MaleNo 101, Taman Kelang, Selangor Table 3
Finding Record From Table 1.Click field name as shown in Figure 21. Figure 21 Icon Find
2.Click icon Find (refer Figure 21) and dialog box Find and Replace will be display as below (Figure 22). Figure 22
3. Type in Noor* inside box Find What to find all the name starting with Noor. 4.Click Find Next button. Name Noorul-Aini bt Ambak will be highlighted at name field (refer figure 23). Figure 23
5.Click Find Next button to find similar name with Noor. Name Noor Asiah bt Zakaria will be highlighted. 6. You can repeat step 3 to find other record. 7. Click File and Close to end this session.