The Basics of Good Database Design in Web Development
Databases are everywhere, including everywhere in the world of web development. Everything from the simplest blogs and directories and to robust user-oriented websites use databases. No matter how complex or simple the website and corresponding database may be though, each takes careful planning in order to run efficiently and also securely. In this article, we'll go over the basics of how to design a good plan for a database, no matter what its final intended use. What Functionality is Needed from the Database? The first method for planning for a database is to simply brainstorm, on paper or otherwise, concerning what the database will need to store, and what the site will need out of it. Image credit: binaryape Think outside the database. What information will they need to derive from the site? Determining Tables and Fields The next phase would be to begin determining exactly what tables and fields one would need in the database. Use a Data Modeling Tool Relational Databases Conclusion
How Do I Restart MySQL Server?
Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt). First login as root user. Now type the following command as per your Linux distro: A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command: * To start mysql server: /etc/init.d/mysqld start * To stop mysql server: /etc/init.d/mysqld stop * To restart mysql server /etc/init.d/mysqld restart Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service: # service mysqld start # service mysqld stop # service mysqld restart (B) If you are using mysql on Debian / Ubuntu Linux then use following command: /etc/init.d/mysql start /etc/init.d/mysql stop /etc/init.d/mysql restart More MySQL articles are here and here.
The many-to-many relationship
The many-to-many relationship is a relationship where multiple rows from table A can correspond to multiple rows in table B. An example of such a relationship is a school where teachers teach students. In most schools each teacher teaches multiple students and each student can be taught by multiple teachers. The relationship between beer distributors and the beers they distribute is a many-to-many relationship too. Note that in database design the question you should ask yourself is not whether a certain relationship exists at the moment, but if a certain relationship is likely to exist in the future. Modelling a many-to-many relationship A many-to-many relationship is modelled with tree tables. All primary keys must be unique. The database design example below shows you the tables that could exist in the many-to-many relationship between Belgian beer brands and their distributors in the Netherlands. Beer tables Another many-to-many example: hotels bookings
Converting your MySQL database to UTF8
This document describes how to convert your MySQL database from the latin1 charset to UTF8. Moodle requires that your Database is now UTF8 and will not upgrade if your database is not. For more information about UTF8 have a look at the doc on unicode. Why? You may see the following error when upgrading your Moodle. It is required that you store all your data in Unicode format (UTF-8). Default Mysql character set Moodle requires UTF8 in order to provide better multilingual support and has done since Moodle 1.8. You need to do two things. 1) Change your mysql to have utf8 as its character set and 2) Change your database to utf8. The descriptions elsewhere in this section cover making the utf8 database versions using mysqldump. To make mysql default to utf8 you can edit /etc/my.cnf as follows. (This was good for ubuntu server lucid 10.04 2.6.32-24-server Jan 2011) In the client section of my.cnf [client] ... .... ... default-character-set=utf8 .... and further down in my.cnf [mysqld] ... ... Explained
The one-to-many relationship
On the page about linking tables I showed you how data from different tables can be linked by defining a foreign key relationship. You saw how orders are linked to customers by including the customer_id as a foreign key in the orders table. Another example of a one-to-many relationship is the relationship that exists between a mother and her children. A mother can have many children and each child has only one mother. (Technically it would be better to speak of a woman and her children instead of a mother and her children, because in a one-to-many relationship a mother can have 0, 1 or many children and a mother with 0 children isn't technically a mother. When one record in table A can be linked to 0, 1 or many records in table B, you are dealing with a one-to-many relationship. A schematic representation of a one-to-manyrelationship. How to identify a one-to-many relationship? When you have two entities ask yourself these questions. How many entities of B can belong to entity A? Examples
Convertir votre base MySQL en UTF-8
Remarque : la traduction de cet article n'est pas terminée. N'hésitez pas à traduire tout ou partie de cette page ou à la compléter. Vous pouvez aussi utiliser la page de discussion pour vos recommandations et suggestions d'améliorations. Ce document explique comment convertir votre base de données interne de Moodle de l'encodage latin1 vers UTF8. Moodle nécessite maintenant l'encodage UTF8 et ne se mettra pas à jour si ce n'est pas le cas. Pour plus d'informations sur l'UTF8, vous pouvez lire la documentation sur Unicode. Pourquoi ? Vous risquez de voir les erreurs suivantes lorsque vous mettez à jour Moodle. It is required that you store all your data in Unicode format (UTF-8). Vous devez faire 2 choses : Modifier votre Mysql pour définir utf8 comme jeu de caractères par défaut Modifier votre base de données pour l'utf8 Jeu de caractères par défaut de Mysql Moodle nécessite UTF8 afin d'assurer une meilleure prise en charge multilingue et ceci est fait depuis Moodle 1.8. Linux & Mac username
Ten Common Database Design Mistakes
No list of mistakes is ever going to be exhaustive. People (myself included) do a lot of really stupid things, at times, in the name of “getting it done.” This list simply reflects the database design mistakes that are currently on my mind, or in some cases, constantly on my mind. I have done this topic two times before. If you’re interested in hearing the podcast version, visit Greg Low’s super-excellent SQL Down Under. I also presented a boiled down, ten-minute version at PASS for the Simple-Talk booth. Before I start with the list, let me be honest for a minute. So, the list: Poor design/planning Ignoring normalization Poor naming standards Lack of documentation One table to hold all domain values Using identity/guid columns as your only key Not using SQL facilities to protect data integrity Not using stored procedures to access data Trying to build generic objects Lack of testing Poor design/planning Ignoring Normalization Are there always 12 payments? Poor naming standards Security
Démarrage et arrêt de httpd
Le RPM httpd installe le script /etc/init.d/httpd qui est accessible à l'aide de la commande /sbin/service. Pour démarrer le serveur, saisissez la commande suivante en étant connecté en tant que super-utilisateur : Pour arrêter le serveur, saisissez la commande suivante en étant connecté en tant que super-utilisateur : L'option restart est une façon rapide d'arrêter et de redémarrer le Serveur HTTP Apache. Pour redémarrer le serveur, saisissez la commande suivante en étant connecté en tant que super-utilisateur : Après avoir modifié le fichier httpd.conf, il n'est toutefois pas nécessaire d'arrêter et de redémarrer le serveur. Afin de recharger le fichier de configuration, saisissez la commande suivante en étant connecté en tant que super-utilisateur : Par défaut, le service httpd ne se lancera pas automatiquement au démarrage.