Get Free Music at www.divine-music.info
Get Free Music at www.divine-music.info

Free Music at divine-music.info

Rabu, 19 September 2012

Pengertian DDL dan DML



DDL (Data Definiton Language)

Pada DDL berkaitan mengenai struktur tabel.
perintah - perintah yang termasuk dalam DDL antara lain :

  • Create

  • Biasa digunakan untuk membuat suatu tabel. Syntax yang digunakan adalah : 
    CREATE TABLE nama_tabel (
    nama_field ke-1 tipe_data lebar_field ), ......,nama_field ke-n tipe_data ( lebar_field ) ) ;
    ]

  • Alter

  • Digunakan untuk mengedit tabel yang telah ada. dalam pengeditan tabel ini ada beberapa kemungkinan, diantaranya adalah mengubah dalam artian memodifikasi salah satu atau beberapa field pada tabel tersebut atau dalam artian menambah satu atau beberapa field pada tabel tersebut.

    syntax umumnya adalah : 

    ALTER TABLE nama_tabel
    ADD | MODIFY nama_field ke-1 tipe_data lebar_field );
    ]

DML (Data Manipulation Language)

DML merupakan bahasa yang berhubungan dengan proses manipulasi data pada tabel, record.

Berikut perintah-perintah yang digunakan dalam DML :

- SELECT : Menampilkan record dari tabel atau view
- INSERT : Menampilkan record dari tabel atau view
- UPDATE : Menghapus record dari tabel
- DELETE : Menghapus record dari tabel
- COMMIT : Menuliskan perubahan ke dalam disk
- ROLLBACK : Membatalkan perubahan yang dilakukan setelah perintah 'COMMIT' terakhir.

Syntax MySQL


Seperti dibahas dalam entri yang sebelumnya SQL sarat dengan berbagai perintah terutama saat kita berada pada MySQL prompt.
Bentuk dari MySQL prompt :
mysql>

Dalam penulisan perintah-perintah ini pun memiliki khasnya sendiri. Dalam windows penulisan perintah-perintah dalam MySQL tidak berpengaruh huruf besar dan kecil, tapi dalam Linux huruf besar dan kecil sangat berpengaruh.

Mengetahui versi MySQL yang kita gunakan:
mysql> SELECT VERSION();

MENAMPILKAN DATABASE:
Syntax => SHOW DATABASES;

MEMBERI CATATAN ATAU KOMENTAR:
Syntax => /* isi dengan komentar atau catatan */

MEMBUAT DATABASE BARU
Syntax => CREATE DATABASE database;

MEMILIH DATABASE
Syntax => USE database;

MENAMPILKAN TABEL
Syntax => SHOW TABLES;

MEMBUAT TABEL BARU
Syntax => CREATE TABLE table(field spesifikasi field, ...)

MENAMPILKAN STRUKTUR TABEL
Syntax => SHOW COLUMNS FROM tabel
atau
Syntax => DESCRIBE tabel

Contoh:
mysql>DESCRIBE biodata;

MENGUBAH STRUKTUR TABEL
Dengan perintah 'ALTER TABLE' kita bisa melakukan terhadap kolom diantaranya:
ADD => melakukan penambahan kolom pada tabel
DROP => menghapus kolom dan index pada tabel
RENAME => mengganti nama tabel
MODIFY => mengubah jenis kolom
CHANGE => mengganti nama kolom sekaligus jenis kolom

Syntax => ALTER TABLE table perintah;

MENGISI DATA
Untuk mengisi data ke database ada 3 cara sebagai berikut:

Cara 1
Syntax => INSERT INTO table(kolom 1, kolom 2, ... kolom n)
VALUES(data_kolom 1, data_kolom 2, ... data_kolom n);


Cara 2
Syntax => INSERT INTO tabel SET kolom1=data_kolom1, kolom2=data_kolom2, ...

Cara 3
Syntax => INSERT INTO tabel VALUES(data_kolom1,data_kolom2, ...)

MENAMPILKAN DATA
Syntax => SELECT kolom FROM tabel WHERE kriteria ORDERED BY kolom

MENGUBAH DATA
Syntax => UPDATE tabel SET kolom=pengubah_data WHERE criteria

Rabu, 12 September 2012


SQL (Structured Query Language) merupakan sebuah bahas yang digunakan untuk mengakses data dalam basis data relasional. Bahasa ini secara de facto merupakan bahasa standar yang digunakan dalam manajemen basis data relasional. Model basis data relasional sendiri merupakan model basis data yang dirancang agar memiliki konsistensi informasi dalam bentuk normalisasi database. Yang secara penerapan dan operasional dikendalikan oleh mesin yang disebut dengan nama Sistem Manajemen Basis Data (SMBD).
Dalam pemakaiannya yang secara umum, SQL terdiri dari dua bahasa, yaitu :

 
Data Definition Language (DDL)

Data Manipulation Language (DML) 

Implementasi DDL dan DML berbeda untuk tiap sistem manajemen basis data (SMBD), namun secara umum implementasi tiap bahasa ini memiliki bentuk standar yang ditetapkan Lembaga Standar Amerika Serikat (ANSI)


 1. Data Definition Language (DDL)

  Data Definition Language (DDL) digunakan untuk mendefinisikan, mengubah, dan menghapus basis data dan objek-objek yang diperlukan dalam basis data, misalnya tabel, view dan sebagainya. Secara umum, DDL yang digunakan adalah 'CREATE' untuk membuat objek baru, 'USE' untuk menggunakan objek, 'ALTER' untuk mengubah objek yang sudah ada, dan 'DROP' untuk menghapus objek.

  2. Data Manipulation Language (DML)
  Data Manipulation Language (DML) digunakan untuk memanipulasi data yang ada dalam suatu tabel. Perintah yang umum digunakan adalah :
-  'SELECT' untuk menampilkan data
-  'INSERT' untuk menambahkan data baru
-  'UPDATE' untuk mengubah data yang sudah ada
-  'DELETE' untuk menghapus data

Beberapa Sistem Manajemen Basis Data (SMBD) memiliki fungsi aggregat, yaitu fungsi-fungsi khusus yang melibatkan sekelompok data. Secara umum fungsi aggregat adalah:
-  'SUM' untuk menghitung total nominal data
-  'COUNT' untuk menghitung jumlah kemunculan data
-  'AVG' untuk menghitung rata-rata sekelompok data
-  'MAX' dan 'MIN' untuk mendapatkan nilai maksimum/minimum dari sekelompok data.
Fungsi aggregat digunakan pada bagian 'SELECT'. Syarat untuk fungsi aggregat diletakkan pada bagian 'HAVING' bukan 'WHERE'.


Kamis, 06 September 2012

Distributed Database


Distributed database

distributed database is a database that is under the control of a central database management system (DBMS) in which storage devices are not all attached to a common CPU. It may be stored in multiple computers located in the same physical location, or may be dispersed over a network of interconnected computers.
Collections of data (eg. in a database) can be distributed across multiple physical locations. A distributed database can reside on network servers on the Internet, on corporate intranets orextranets, or on other company networks. Replication and distribution of databases improve database performance at end-user worksites. [1]
To ensure that the distributive databases are up to date and current, there are two processes: replication and duplication. Replication involves using specialized software that looks for changes in the distributive database. Once the changes have been identified, the replication process makes all the databases look the same. The replication process can be very complex and time consuming depending on the size and number of the distributive databases. This process can also require a lot of time and computer resources. Duplication on the other hand is not as complicated. It basically identifies one database as a master and then duplicates that database. The duplication process is normally done at a set time after hours. This is to ensure that each distributed location has the same data. During the duplication process, changes to the master database only are allowed. This is to ensure that local data will not be overwritten. Both of the processes can keep the data current in all distributive locations.[2]
Besides distributed database replication and fragmentation, there are many other distributed database design technologies. For example, local autonomy, synchronous and asynchronous distributed database technologies. These technologies' implementation can and does depend on the needs of the business and the sensitivity/confidentiality of the data to be stored in the database, and hence the price the business is willing to spend on ensuring data security, consistency and integrity.




Architecture


A database user accesses the distributed database through:
Local applications
applications which do not require data from other sites.
Global applications
applications which do require data from other sites.
A distributed database does not share main memory or disks.

[edit]Important considerations

Care with a distributed database must be taken to ensure the following:
  • The distribution is transparent — users must be able to interact with the system as if it were one logical system. This applies to the system's performance, and methods of access among other things.
  • Transactions are transparent — each transaction must maintain database integrity across multiple databases. Transactions must also be divided into sub-transactions, each sub-transaction affecting one database system.
There are mainly two approaches to store a relation r in a distributed database system:
A) Replication
B) Fragmentation
A) Replication: In replication, the system maintains several identical replicas of the same relation r in different sites.
  • Data is more available in this scheme.
  • Parallelism is increased when read request is served.
  • Increases overhead on update operations as each site containing the replica needed to be updated in order to maintain consistency.
B) Fragmentation: The relation r is fragmented into several relations r1, r2, r3....rn in such a way that the actual relation could be reconstructed from the fragments and then the fragments are scattered to different locations. There are basically two schemes of fragmentation:
  • Horizontal fragmentation - splits the relation by assigning each tuple of r to one or more fragments.
  • Vertical fragmentation - splits the relation by decomposing the schema R of relation r.

[edit]Advantages

  • Management of distributed data with different levels of transparency like network transparency,fragmentation transparency, replication transparency, etc.
  • Increase reliability and availability.
  • Easier expansion.
  • Reflects organizational structure — database fragments are located in the departments they relate to.
  • Local autonomy or site autonomy — a department can control the data about them (as they are the ones familiar with it.)
  • Protection of valuable data — if there were ever a catastrophic event such as a fire, all of the data would not be in one place, but distributed in multiple locations.
  • Improved performance — data is located near the site of greatest demand, and the database systems themselves are parallelized, allowing load on the databases to be balanced among servers. (A high load on one module of the database won't affect other modules of the database in a distributed database.)
  • Economics — it costs less to create a network of smaller computers with the power of a single large computer.
  • Modularity — systems can be modified, added and removed from the distributed database without affecting other modules (systems).
  • Reliable transactions - Due to replication of database.
  • Hardware, Operating System, Network, Fragmentation, DBMS, Replication and Location Independence.
  • Continuous operation.
  • Distributed Query processing.
  • Distributed Transaction management.
Single site failure does not affect performance of system. All transactions follow A.C.I.D. property: a-atomicity, the transaction takes place as whole or not at all; c-consistency, maps one consistent DB state to another; i-isolation, each transaction sees a consistent DB; d-durability, the results of a transaction must survive system failures. The Merge Replication Method used to consolidate the data between databases

[edit]Disadvantages

  • Complexity — extra work must be done by the DBAs to ensure that the distributed nature of the system is transparent. Extra work must also be done to maintain multiple disparate systems, instead of one big one. Extra database design work must also be done to account for the disconnected nature of the database — for example, joins become prohibitively expensive when performed across multiple systems.
  • Economics — increased complexity and a more extensive infrastructure means extra labour costs.
  • Security — remote database fragments must be secured, and they are not centralized so the remote sites must be secured as well. The infrastructure must also be secured (e.g., by encrypting the network links between remote sites).
  • Difficult to maintain integrity — but in a distributed database, enforcing integrity over a network may require too much of the network's resources to be feasible.,
  • Inexperience — distributed databases are difficult to work with, and as a young field there is not much readily available experience on proper practice.
  • Lack of standards — there are no tools or methodologies yet to help users convert a centralized DBMS into a distributed DBMS.
  • Database design more complex — besides of the normal difficulties, the design of a distributed database has to consider fragmentation of data, allocation of fragments to specific sites and data replication.
  • Additional software is required.
  • Operating System should support distributed environment.
  • Concurrency control: it is a major issue. It can be solved by locking and timestamping.