Kada pravite baze podataka i tabele, trebalo bi da smisljate imena (identifikatore), koja su jasna, znacajna i koja se lako kucaju.
Identifikatori:
Identifikatori:
- treba da sadrze samo slova (a-z, A-Z), brojeve (0-9) i donju crtu (_) bez razmaka.
- ne treba da budu isti kao postojece kljucne reci (kao neki SQL pojam ili ime funkcije)
- treba voditi racuna od malim i velikim slovima
- ne smeju da budu duzi od 64 znaka tj. 64 bajta (priblizno)
- moraju da budu jedinstveni u svom opsegu
Objasnjenje: rec treba smo upotrebili sa znacenjem da je dobra praksa u pitanju a ne stroga pravila. Postovanje ovih preporuka pomaze da se izbegnu komplikacije. Poslednje pravilo znaci da tebela ne moze da ima dve kolone koje se isto zovu i da baza podataka ne moze da ima dve tabele koje se isto zovu.
Imenovanje elemenata baze podataka:
1) Odredite ime baze podataka.
Napomena: samo pazite da ime baze podataka bude jedinstveno za taj MySQl server.
U ovom primeru, ime baze ce biti motori.
2) Odredite imena tabela. Imena tabela moraju da budu jednistvena.
U ovom primeru, u kojem cuvamo informacije o registraciji motociklista, jedina tabela ce se zvati, motociklisti.
Tabela motociklisti
ime kolone primer
id_motocikliste 432
ime Nikola
prezime Nikolic
email nikolan@example.com
lozinka pevec01
datum_registracije 2015-12-12 05:28:03
3) Odredite imena kolona za svaku tabelu.
U ovom primeru, tabela motociklisti imace kolone za cuvanje identifikatora (id_motocikliste), imena (ime), prezimena (prezime), jedne email adrese (email), lozinke (lozinka) i datume registracija (datum_registracije).
1. Pokrenite XAMPP. Kliknite na Admin u liniji MySQL-a ili ukucajte u address bar http://localhost/phpmyadmin/
2. Izaberite karticu Databases, u prvo polje upisite ime baze podataka, u ovom primeru, motori, za drugo polje izaberite utf8_unicode_ci, ili onaj koji Vama odgovara.
3. Klik na dugme "Create".
4. U polje "Name:" upisite ime vase tabele, u ovom primeru, motociklisti. U polje "Number of columns:" upisite 6.
5. Klik na dugme "Go".
When creating databases and tables, you should devise names (identifiers), which are clear, significant and that can easily type.
Identifiers:
- should contain only letters (a-z, A-Z), numbers (0-9) and the underscore character (_) with no spaces.
- should not be the same as the existing keywords (as a SQL term or function name)
- should take care of small and capital letters
- must not be longer than 64 characters, ie. 64 bytes (approximately)
- must be unique in its scope
Explanation: we used the word should which means the good practice rather than strict rule. Respecting these recommendations helps avoid complications. The last rule means that table can not have two columns that have the same name and the database can not have two tables that are also with same name.
Naming of database elements:
1) Determine the name of the database.
Note: just make sure that the database name is unique to the MySQL server.
In this example, the database name will be the motorcycles.
2) Determine the table names. Table names must be the uniform.
In this example, in which we will store the information on the registration of motorcyclists, only one table will be named, motorcyclists.
Table motorcyclists
column name example
motorcyclist_id 432
first_name Cory
last_name Hansen
email coryh@example.com pass bmw01can
registration_date 2015-12-12 05:28:03
3) Determine column names for every table.
In this example, the table motorcyclists will have columns for storing identifiers (motorcyclist_id), name (first_name), last name (last_name), one e-mail address (email), password (pass) and registration date (registration_date).
1. Start XAMPP. Click on the Admin in line of MySQL or type in the address bar http://localhost/phpmyadmin/
2. Select the tab Databases, in the first field, enter the name of the database, in this example, the motorcycles, for the second field select utf8_unicode_ci, or the one that suits you.
3. Click the button "Create".
4. In the "Name" enter the name of your table, in this example, motorcyclists. In the "Number of columns:" enter the 6.
5. Click the button "Go".
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.