Creating relationships table in the database for web laravel


Relation between a database is sometimes required to present an amalgamation of information in one table. For example, when it will make a report values for which data from several tables, and it is impossible and inefficient if it is made a new table to input their own values that should be derived from other tables.

Examples of application relation table:

  1. make a your own database (“db_student”).
  2. next, make table in database : (in the table “dosen” who became the primary key is a nip, and in the table “mahasiswa” who became the primary key is a nrp, and in the table “matakuliah” who became the primary key is a kode, and the last table “nilai” there is no primary key.

    tabel_relasi

  3. fill of each table with a value.
  4. After finish all entry in table, now return to database and click SQL menu, and write this script :

    create view LaporanNilai as select mahasiswa.nrp, mahasiswa.nama, mahasiswa.jurusan, matakuliah.matakuliah, dosen.dosen, nilai.nilai, nilai.mutu from mahasiswa, matakuliah, dosen, nilai where nilai.nrp=mahasiswa.nrp and nilai.kode=matakuliah.kode and nilai.nip=dosen.nip;

  5. After finish and executed, it will be formed a view table and show a result from a relationships table.

    hsl_relasi.jpg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s