Website Development Prices

Search Blog

Tuesday, December 22, 2015

Biranje ostalih svojstava kolona (Choosing other column properties)

Dva usko povezana pojma sa projektovanjem baza podataka su indeksi i kjucevi.

Indeks je nacin da se od baze podataka zahteva paznja prema vrednostima konkretne kolone ili kombinacije kolona.

Kljuc u tabeli baze podataka je sastvani deo procesa "normalizacije" koji se koristi u projektovanju slozenijih baza podataka. Postoje sve vrste kljuceva: primarni i strani (eng. foreign). Svaka tabela treba da ima tacno jedan kljuc, aprimarni kljuc jedne tabele je cesto povezan kao strani kljuc druge tabele.

Primarni kljuc mora da postuje tri pravila:
  • uvek mora da ima vrednost
  • ta vrednost ne sme nikad da se menja
  • ta vrednost mora za svaki zapis da bude jedinstvena u toj tabeli
1. Pokrenite XAMPP. Kliknite na Admin u liniji MySQL-a ili ukucajte u address bar http://localhost/phpmyadmin/.
2. Sa leve strane odaberite bazu podataka, u ovom primeru, motori i kliknite na tabelu motociklisti.


3. Kliknite na karticu Structure, pa u redu id_motocikliste kliknite olovku Change.

  A) U nasem primeru, tabela id_motocikliste cemo odrediti kao primarni kljuc (PRIMARY KEY), sto je opis kolone i uputstvo MySQL-u da kolonu indeksira.


 4. U redu id_motocikliste, kliknite na kljuc Primary, pa na OK.






B) Posto je id_motocikliste broj, koloni se dodaje i opis AUTO_INCREMENT (A_I), sto upucuje MySQL da za svaki zapis koji se dodaje upotrebi sledeci veci broj. U PhpMyAdmin-u, cekirajte polje ispod A_I.

 

C) Odredite koje kolone ne mogu da imaju vrednost NULL. U nasem primeru, sva polja su obavezna, tako da ne mogu da imaju vrednost NULL. U PhpMyAdmin-u, polje ispod Null ostavicemo prazno.


D) Svaki numericki tip koji nikad nece imati negativne vrednosti oznacite sa UNSIGNED. U nasem primeru, polje id_motocikliste, broj, treva da bude UNSIGNED da bi uvek bio pozitivan. 

5. Ponovite korak 3. Ispod Attributes izaberite UNSIGNED i kliknite na Save.



The two concepts of the design database are indexes and the keys.

The index is a way to get attention  from the database to the values ​​of specific columns or combination of columns.

The key in the table of database is a constituting part of the process of "normalization" and is used in the design of more complex databases. There are two kinds of keys: primary and foreign. Each table has exactly one key, the primary key of one table is often associated as a foreign key to another table.

The primary key must respect three rules:

  •     should always have a value
  •     this value should never be changed
  •     the value for each record must be unique to the table
1. Start XAMPP. Click on the Admin in line MySQL or type in the address bar http://localhost/phpmyadmin/.

2. From the left, select the database, in this example, motorcycles and click on the table motorcyclists.



3. Click the tab Structure and than in row of motorcyclist_id click pen Change.
 


A) In our example, the table motorcyclist_id  we will define as the primary key, which is a description of the column and instructions MySQL to index column.

 4. In row motorcyclist_id, click the key Primary, and OK.
 





B) Since the motorcyclist_id is number, to the column is added description AUTO_INCREMENT (A_I), which indicates that MySQL for each record that is added will use the next higher number. In phpMyAdmin in, check the box below A_I.




C) Determine which columns can not have a NULL value. In our example, all fields are required, so you can not have a NULL value. In phpMyAdmin, the field below Null we will leave empty.
 



D) Any numerical type who will never have a negative value mark with UNSIGNED. In our example, the field motorcyclist_id, is number, the number should be UNSIGNED, so it would be always positive.

5. Repeat step 3 Under Attributes select UNSIGNED and click Save.







No comments:

Post a Comment

Note: Only a member of this blog may post a comment.