Selasa, 30 Oktober 2012

Pembuatan Database dengan Database Acces

Hari ini, Rabu, 31 Oktober 2012, saya diminta untuk membuat langkah - langkah membuat database klinik dengan menggunakan Database Microsoft Access. Langkah - langkah dalam membuat database klinik ini adalah , saya harus membuat :
1.Table Pasien       :    dengan design : id_pasien  (text) ; nama_pasien (text) ; tanggal_lahir (date/time) ;                                alamat (text) ; no_telp (number).     
2.Table Dokter      :    dengan design : id_dokter (text) ; nama_dokter (text) ; tanggal_lahir (date/time) ; alamat (text) ; no_telp (number) ; keahlian (text) ; tarif (number).
3. Table Diagnosa :    dengan design : id_diagnosa (text) ; id_pasien (text) ; id_dokter (text) ; tanggal_periksa (date/time) ;  hasil_diagnosa (text).
4. Table Obat         :    dengan design : id_obat (text) ; nama_obat (text) ; kegunaan (text) ; harga_obat (number).
5. Table Resep      :    dengan design : id_resep (text) ; id_dokter (text) ; id_pasien (text) ; isi_resep (text).



setelah membuat database nya, saya juga membuat relationship nya..
ini adalah contoh relationship :








itulah contoh database yang saya buat.....
terimakasih..............................................


Selasa, 04 September 2012

Design Forms Database Access


Like many desktop database application development tools, Microsoft Access has very robust facilities for creating forms. For reporting applications you will use yourself you may not need many forms. But if you are setting up a database for someone else to use you will want to create a set of forms for data entry, report selection, etc.
The purpose of this article is not to present a tutorial on how to design a form. There are many good sources of information on that. Rather, I want to focus on the effect that table relationships and queries have on the basic structure of the forms. Along the way we'll see just how much of the legwork can be done for you by the Access form wizard, especially if you have properly designed your tables, queries and relationships. So let's cover a few basics first.

Background
Bound vs Unbound Forms
Access can create two types of forms: bound and unbound. A bound form is connected to a table or query via a record source property. An unbound form has no record source. It can be used to collect criteria, such as a date range, for reports, searches, etc. This article focuses on bound forms.
Data Sources
Each form has one (and only one) record source. This is an important point since it would seemingly imply that a form can be used to update only one table. But this is not so. A query which draws from more than one table can also be used. If it is updatable then you can update multiple tables via one form (more about this later). In the example below we are using a work_orders table. It could just as easily have been a query.
Another way to update multiple tables is through subforms.
Subforms
Access has the ability to create subforms. These are similar to regular forms and have their own record source. Once created they can be embedded in or linked to a main form and Access will automatically maintain the relationship between the data in the two forms.
The remainder of this article will discuss form creation in light of existing tables, relationships and queries. We'll start with tables and then delve into using queries.

Simple Data Entry Forms
You did do a thorough job of setting your field properties, didn't you? If not go back and finish this job now. The Form Wizard will use the caption property to generate the field labels. If you've set these already then you will automatically get meaningful labels on your forms with no further work.
A simple data entry form is all that's needed to update many of the tables in your database. For example customers, suppliers, vendors, parts, locations, etc. You should have a data entry form for each of these. It won't handle your transactions or fancier displays but we'll get to that later. Here's a real simple form for updating employee information for a sample database.
Notice the record source. This form was created simply by running the Form Wizard, selecting the employees table as the record source and using the columnar format. Of course I added a few things and moved a field or two, but basically the wizard did all the work. Do note that you should also set the caption property for the form.
Name your form with a prefix of frm. For example: frmEmployees.One-to-many Forms
These are sometimes called master-detail forms. The basic idea is that one table is the parent or master table. The other is the child or detail. The parent is the record source for a main form in which a subform is embedded with the child table as the record source. There are several ways to create one-to-many forms. First let's have a look at what one looks like. It's a simple example showing a work order with labor tickets applied.
The main form uses the work_orders table as the record source. The subform uses the labor table. There is a foreign key, wono, in the labor table which refers to the primary key, wono, in the work_orders table. Here is what the relationship look like.
We'll create this the manual way. Once we know what is going on we'll look at how to speed the process up with the Form Wizard.
There are three basic steps.
  1. Create the subform
  2. Create the main form
  3. Add the subform to the main form
1. Create the subform
Use the From Wizard to create a form just as for a simple data entry form. But select a tabular or dataheet format. Remove extraneous controls, labels, etc. Use the child table as the record source. When done you should have something that looks like the one below (I did mine in tabular format).
Save it. The convention for subform name prefixes is sfrm. Some people use frmsub.
2. Create the Main Form
Create the main, or master, form using a columnar format and the parent table as the record source.
3. Add the Subform to the Main Form
Drag and drop the subform on the the main form. Voila. You now have a master-detail form.
One-to-Many Forms (Cont'd)
Below is the property sheet for the subform. Note the link master and link child properties. These show the foreign key, link child, referencing the master's primary key. Both are wono(work order number) in this case. Clicking on the ellipsis symbol, "...", will bring up a dialog to configure the linking fields if you need to change them (which you shouldn't, ordinarily).
Creating a one-to-many Form in one step
Now that we know what is going on let's look at how to speed the process up with the Form Wizard. Remember how we created a subform for the child table, a main form for the parent table, and then linked them? Well, the wizard can figure this out, too. Or, at least it can with a little coaching.
Launch the Form Wizard and supply both tables as the record sources. You will get a dialog box asking how you want to arrange the data.
By selecting how you view the data you can control the type of form that gets created. The example above will build a work_orders main form with a labor subform just as we did earlier - but in one step! Selecting by Labor would cause a single form to be created based on a query which Access would create automatically.
The Subform control
One more point - there is also a subform control you can use if it's installed. (Marked in red below). Drag and drop it on to your main form and follow the dialog.

Many-to-Many Forms
There really isn't a many-to-many form, per se. Typically when you have a many-to-many relationship you will build a main form with a subform. Remember that we represent a many-to-many relationship with the two original tables plus a third intersection table. Build a main form based on one of the original parent tables. The subform will refer to two tables: the intersection table and the other parent. How is this done? With a query.
You can either create the query yourself or have the wizard do it for you by adding fields from all three tables.


Many-to-One Forms (Cont'd)
Here is a form, dressed up a little, based on the previous query. Empno and wono are the composite primary key of the labor ticket. They are also foreign keys to the primary keys in the employees and work_orders tables. By selecting an empno or work_order no from the drop downs, the corresponding information from the employees and work_order tables is automatically filled in on the form.
This same technique could be used to display shipping and billing addreses for a customer, etc. Equally the fields could have been displayed in tabular format like an invoice line-item. This is illustrated below.

Database Relationship

Database Relationship


Definition - What does Relationship (Databases) mean?

A relationship, in the context of databases, is a situation that exists between two relational database tables when one table has a foreign key that references the primary key of the other table. Relationships allow relational databases to split and store data in different tables, while linking disparate data items.

For example, in a bank database a CUSTOMER_MASTER table stores customer data with a primary key column named CUSTOMER_ID; it also stores customer data in an ACCOUNTS_MASTER table, which holds information about various bank accounts and associated customers. To link these two tables and determine customer and bank account information, a corresponding CUSTOMER_ID column must be inserted in the ACCOUNTS_MASTER table, referencing existing customer ids from the CUSTOMER_MASTER table. In this case, the ACCOUNTS_MASTER table’s CUSTOMER_ID column is a foreign key that references a column with the same name in the CUSTOMER_MASTER table. This is an example of a relationship between the two tables.

The fundamental feature that differentiates relational databases from other database types (e.g., flat-files) is the ability to define relationships.

                                                                                                           Wednesday, September 5th 2012

Selasa, 31 Juli 2012

Database (Bahasa Indonesia)

Apa itu Database?

Database bisa dikatakan sebagai suatu kumpulan dari data yang tersimpan dan diatur atau diorganisasikan sehingga data tersebut bisa diambil atau dicari dengan mudah dan efisien. Sebagai contoh sederhana dari database adalah buku telepon yang mungkin sering Anda lihat.
Bagaimana halnya dengan database dengan sistem database dengan menggunakan komputer? Hal tersebut sama saja seperti database yang sifatnya manual (seperti contoh buku telepon di atas) hanya saja dengan adanya komputer maka informasi yang ada di dalam database akan sangat mudah untuk di-update dan sangat cepat untuk dicari. Software atau aplikasi yang bertugas untuk mengatur, menyimpan, memodifikasi data disebut dengan software database engine dan lebih resminya disebut dengan DBMS (Database Management System). Ada banyak sekali aplikasi DBMS ini mulai yang berjalan di komputer personal (PC) sampai ke komputer skala mainframe. Contoh-contoh dari aplikasi database engine misalnya seperti:
SQL Server, dibuat oleh Microsoft.
MS Access, dibuat oleh Microsoft.
Oracle Database, dibuat oleh Oracle.
MySQL, dibuat oleh MySQL AB.
Firebird, dibuat oleh komunitas open source berdasarkan dari kode Interbase.
PostgreSQL, dibuat oleh komunitas open source.
DB2, dibuat oleh IBM.
Masih banyak lagi sederet nama database engine yang ada di dunia ini. Anda bisa mencarinya dengan keyword ‘database engine’ atau ‘database server’.

Jika Anda bertanya “Apa saja sih aplikasi yang bisa menggunakan database?”, wah jawabannya akan sangat banyak sekali, beberapa diantaranya adalah:
Sistem perpustakaan yang berbasis komputer, pasti membutuhkan database yang besar untuk merawat data buku yang dimilikinya.
Sistem ATM (Automatic Teller Machine), pasti membutuhkan database yang besar untuk mengambil dan meng-update data saldo uang misalnya.
Sistem reservasi tiket pesawat, pasti membutuhkan database untuk menyimpan data reservasi tiket.
Sistem inventory, pasti membutuhkan database untuk menyimpan data inventory termasuk updating data stok barang dan lain sebagainya.
Contoh di atas hanyalah sebagian kecil dari aplikasi yang membutuhkan database karena pada kenyataannya semua kegiatan bisnis yang dikomputerisasikan pasti membutuhkan sistem database sebagai media penyimpanan. Database tersebut selain digunakan untuk menyimpan data transaksi juga akan digunakan untuk menampilkan laporan yang bisa digunakan pihak manajemen sebagai sumber untuk pengambilan keputusan. Untuk sistem database yang lebih canggih malah sudah terdapat fasilitas analisa data sehingga bisa memprediksi keadaan yang akan terjadi berdasarkan data yang sudah ada sebelumnya.
     
                                                                                                               Wednesday, August 1st 2012


> What Is a Database?

A database is a tool for collecting and organizing information. Databases can store information about people, products, orders, or anything else. Many databases start as a list in a word-processing program or spreadsheet. As the list grows bigger, redundancies and inconsistencies begin to appear in the data. The data becomes hard to understand in list form, and there are limited ways of searching or pulling subsets of data out for review. Once these problems start to appear, it's a good idea to transfer the data to a database created by a database management system (DBMS), such as Office Access 2007.

A computerized database is a container of objects. One database can contain more than one table. For example, an inventory tracking system that uses three tables is not three databases, but one database that contains three tables. Unless it has been specifically designed to use data or code from another source, an Access database stores its tables in a single file, along with other objects, such as forms, reports, macros, and modules. Databases created in the Access 2007 format have the file extension .accdb, and databases created in earlier Access formats have the file extension .mdb. You can use Access 2007 to create files in earlier file formats (for example, Access 2000 and Access 2002-2003).

> Tables

A database table is similar in appearance to a spreadsheet, in that data is stored in rows and columns. As a result, it is usually quite easy to import a spreadsheet into a database table. The main difference between storing your data in a spreadsheet and storing it in a database is in how the data is organized.

To get the most flexibility out of a database, the data needs to be organized into tables so that redundancies don't occur. For example, if you're storing information about employees, each employee should only need to be entered once in a table that is set up just to hold employee data. Data about products will be stored in its own table, and data about branch offices will be stored in another table. This process is called normalization.

> Forms

Forms are sometimes referred to as "data entry screens." They are the interfaces you use to work with your data, and they often contain command buttons that perform various commands. You can create a database without using forms by simply editing your data in the table datasheets. However, most database users prefer to use forms for viewing, entering, and editing data in the tables.

Forms provide an easy-to-use format for working with the data, and you can also add functional elements, such as command buttons, to them. You can program the buttons to determine which data appears on the form, open other forms or reports, or perform a variety of other tasks. For example, you might have a form named "Customer Form" in which you work with customer data. The customer form might have a button which opens an order form where you can enter a new order for that customer.

> Reports

Reports are what you use to summarize and present data in the tables. A report usually answers a specific question, such as "How much money did we receive from each customer this year?" or "What cities are our customers located in?" Each report can be formatted to present the information in the most readable way possible.
A report can be run at any time, and will always reflect the current data in the database. Reports are generally formatted to be printed out, but they can also be viewed on the screen, exported to another program, or sent as e-mail message.

> Queries

Queries are the real workhorses in a database, and can perform many different functions. Their most common function is to retrieve specific data from the tables. The data you want to see is usually spread across several tables, and queries allow you to view it in a single datasheet. Also, since you usually don't want to see all the records at once, queries let you add criteria to "filter" the data down to just the records you want. Queries often serve as the record source for forms and reports.
Certain queries are "updateable," meaning you can edit the data in the underlying tables via the query datasheet. If you are working in an updateable query, remember that your changes are actually being made in the tables, not just in the query datasheet.
Queries come in two basic varieties: select queries and action queries. A select query simply retrieves the data and makes it available for use. You can view the results of the query on the screen, print it out, or copy it to the clipboard. Or, you can use the output of the query as the record source for a form or report.
An action query, as the name implies, performs a task with the data. Action queries can be used to create new tables, add data to existing tables, update data, or delete data.

> Macros

Macros in Access can be thought of as a simplified programming language which you can use to add functionality to your database. For example, you can attach a macro to a command button on a form so that the macro runs whenever the button is clicked. Macros contain actions that perform tasks, such as opening a report, running a query, or closing the database. Most database operations that you do manually can be automated by using macros, so they can be great time-saving devices.

>Modules

Modules, like macros, are objects you can use to add functionality to your database. Whereas you create macros in Access by choosing from a list of macro actions, you write modules in the Visual Basic for Applications (VBA) (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.) programming language. A module is a collection of declarations, statements, and procedures that are stored together as a unit. A module can be either a class module or a standard module. Class modules are attached to forms or reports, and usually contain procedures that are specific to the form or report they're attached to. Standard modules contain general procedures that aren't associated with any other object. Standard modules are listed under Modules in the Navigation Pane, whereas class modules are not.


                                                                                                             Wednesday, August 1st 2012