SUBQUERIES (NESTED SELECT STATEMENT)

Kali ini saya akan mencoba menjelaskan mengenai subqueires. Apa itu subqueries ? subqueries di dalam ilmu database merupakan query yang mengandung query yang lain atau jikalau kita menggunakan sebuah select statement, subqueries dapat diartikan select dalam select statement. Subqueries  biasa diletakkan setelah kata 'where' dan subqueries bisa mengembalikan nilai dari banyak baris atau bisa juga mengembalikan  nilai lebih dari satu kolom. Kegunaan subqueries agar memudahkan apabila terjadinya self join atau saat membuat view

Untuk lebih memperdalam subqueries, saya akan membuat sebuah database yang didalamnya ada beberapa tabel yang nantinya akan dijelaskan lebih lanjut bagaimana contoh penulisan atau aturan dalam subqueries melalui soal-soal sederhana tapi mudah-mudahan dapat dipahami dengan baik oleh teman-teman sekalian.

Tabel:
  1. tmanggota
     2. tmbuku



   3. ttpeminjaman

NB: Jika di lihat dari ketiga tabel diatas, tabel ttpeminjaman merupakan tabel transaksi yang terdapat dua buah foreign key dari tabel tmanggota(kode) dan tmbuku(kode)
sekarang, saya akan membuat beberapa contoh subqueries dari ketiga tabel tersebut

contoh 1 :
Tampilkan banyaknya penerbit yang menampung buku yang di buat oleh 'Andy Setiawan'

query :





output :

contoh 2 :
Tampilkan jumlah buku yang diterbitkan oleh penerbit Gramedia

query :


output :


contoh 3 :
Tampilkan nama pengarang yang bukunya diterbitkan oleh penerbit yang sama dengan Andy Setiawan

query :


output :

contoh 4 :
Tampilkan jumlah terbanyak buku-buku yang didistibusikan oleh penerbit 'Pustaka Media'

query :


output :

contoh 5 :
Tampilkan data-data peminjaman buku dari anggota yang bernama 'Bimantoko'
query :


output :





contoh 6 :
Tampilkan nama anggota yang memiliki denda terbesar dalam transaksi peminjaman

query :





output :




contoh 7 :
Tampilkan jumlah keseluruhan denda yang diberlakukan untuk anggota yang bernama 'Octo Siswardhono'

query :




output :




contoh 8 :
Tampilkan data-data peminjaman dari anggota bersemester delapan yang meminjam buku di antara tanggal 1 Januari 2009 s/d 1 Januari 2010

query :



output :



contoh 9 :
Tampilkan judul buku serta data-data peminjaman lain yang dipinjam dari anggota bersemester empat dan anggota tersebut hanya meminjam sebuah buku

query :



output :



contoh 10 :
Tampilkan judul dan penerbit yang paling banyak dipinjam oleh anggota bersemester delapan

query :



output :


OOP

this time , I'll explain Object Oriented Programming Concept(OOP Concept), structure class, package, access control, inheritance, polymorphism, and little example of array and how to manipulate it.

OOP
The Object Oriented paradigms suggest we should model instructions in a computer program with the data they manipulate and store these as components together. One advantage of doing this is we get reusable software components. OOP paradigm aims to help overcome these problems by helping with the analysis and design tasks during the initial software development phase and by ensuring software is robust and maintanable.

Abstraction and encapsulation are fundamental principles of Object Oriented approach to software development. Abstraction allow us to consider complex ideas while ignoring irrelevant detail that would confuse us. Encapsulation allow us to focus on what something does without considering the complexities of how it works. Others fundamental principles of Object Orientation are Generalization/specialization ( which allow us to make use of inherintace ) and Polymorphism.
Generalisation allow us to consider general categories of objects which have common properties and then define specialised sub classes that inherit properties of the general categories. Polymorphism which is the ability to interact with a object as it's generalized category regardless of it's more specialised category.

Class
Class are the basic components of any object oriented software system. A class should typically be recognizable by a non-programmer domain even if associated with exixting problems and code contained in a class should be relatively independent

Package
A package is not just a visual representation of a group of classes instead a 'package' is a directory containing a group of related classes(and interfaces). Package allow us to provide a level of organisation and encapsulation above that of individual classes.

Access Control
OOP provides several types of access rights to the variable (attributes), the method and even class. Type of access rights, which are Public, Private, or Protected. This is one of the most important part of OOP, so that programmers who want to learn OOP required to understand the concept of accessing this data in OOP.

Inheritance
Giving the properties of a major class(super-class) to the other classes(sub-class) that have similiar properties. The main class is usually a genereal/global, while the sub-classes are specific/special

Polymorphism
The ablity of variables to be used as reference or a reference object of different type, and automatically can call the method specific to each type

Array
Substansial program would require a lot of variables. We can only declare variables one by one. Suppose that we need five variables with integer types, we can declared with int x,y,z.
This is still very small, what if we need 500 variables?
This would be inefficient. Thus we need or used arrays.
But before we decide to used array, we must also examine whether the data will be accessed sequentially? if yes then we can use arrays,  but the data will not be accessed sequentially, should declare itself .
 int [] arr = new int[100];

Source : OOP

UML Tutorial - Class Diagrams

Hey Fella, one week ago I learned about UML on OOP-II Class..now I try to share my knowledge about how to make class diagrams with Java also used NetBeans Apps for support this tutorial. Previously I given example that you can see here about class diagram. After you see my previous post, is it diffuclt or easy to realize that ? well, I'll lead you how accurate steps to make class diagram and if you don't mind, please follow these instructions :

  • First of all, installed NetBeans on your computer/PC whatever the series but I used NetBeans 6.7 for this time

  • After the main page of NetBeans appears, create new project: File > New Project 

  • Choose project, categories: Java , projects: Java Application and click Next

  • Fill Project Name:( DependOnYou ) ; Project Location: ( where the project will be saved actually on NetBeans Projects  Folder ) ; click Finish

  • This is the result after create JavaUML Project:

  • Then, create UML project (File > New  Project); Choose Project Categories: UML; Projects: Java-Platform Model; click Next
 
  • Fill Project Name: ( DependOnYou ); Project Location: ( where the preiviously main project JavaUML folder have been stored ); click Finish
  •  Choose Class Diagram and Fill Diagram Name as you want, click Finish
  •  Now lets make your own Class Diagram as you want. You can use all of pallete to helping you to do on the right side

  • Start from package, why package ? we need package diagrams to show the general architecture of a large system. Even modest systems can be broken down into a few basic components i.e packages. You can double click to give the name of package or fill Name section on Properties

  • Now, you can create class and choose how the relationship between the package. After that, you can create an attributes with right-click on class and you can decide where's field will be the primary key in every class (on properties)

  • This is the result if you combine class and the relationship like my previous post

  • The last steps, to see whether the class diagrams that we make is correct then, you can do Run Main Project (F6)


just share to all my friends, downloaded in here :

class diagram

this is one of simple implementation from Unified Model Language (UML) which is had four of the most common diagrams (class diagrams, object diagrams, sequence diagrams and package diagrams) but now, focus with simple example of class diagram !

e.g :





relational database

A relational database usually described by using two-dimensional tables consisting of rows and columns which data can be accessed or reassembled in many different ways without having to reorganize the database tables. Hence, a relational database matches data by using common characteristics found within the data set. The resulting groups of data are organized and are much easier for many people to understand. After the original database creation, a new data category can be added without requiring that all existing applications be modified. 
Several terms in the relational database include the following:


Relation   : A table consisting of several columns and several rows.
Attribute  : Column names in a relation
Tuple        : Rows in a relation ,represents an object and information 
                   about that object. Object are typically physical objects or 
                   concepts


Domain     : A valid set of value for one or more attributes
Degree      : The number of attributes in a relation
Cardinality: The number of tuples in a relation

Now, wanna show you  one of example which is how's the term and describing a relational database