background preloader

Databases

Facebook Twitter

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. 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. 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.

A distributor will in most cases distribute more than one type of beer and each type of beer can be distributed by multiple distributors. 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. If at present all distributors distribute multiple types of beers, but each type of beer is distributed by only one distibutor, you are looking at a one-to-many relationship. Modelling a many-to-many relationship All primary keys must be unique. 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. For all database designs, there are a set of standard rules and best practices to follow, all of which can help a database stay organized and help to team up with the respective site in a smart and efficient way. 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. Determining Tables and Fields Conclusion.

Redis

SQLite from Python: Database Basics video tutorial - Developing emol! - Learn: beginners, pyopengl, documentation, user, sqlite, planning, deb, while, data, wxpython, newbies, objects, http, firefox, copyright, databases, public, launchpad, bazaar, good, DB normalization. Mysql. Installation Installez le paquet mysql-server. L'installation de ce paquet doit se faire en utilisant dans un terminal la commande sudo apt-get install mysql-server Ne pas simplement cliquer sur le lien apt ci-dessus. Le support de l'extension PHP Data Objects PHP Data Objects (PDO) est installé par défaut avec php5-mysql lors de l'installation de php5.

Utilisation Démarrage Pour démarrer le serveur MySQL, tapez la commande suivante dans un terminal: sudo service mysql start Redémarrage Pour redémarrer le serveur MySQL, tapez la commande suivante dans un terminal: sudo service mysql restart Arrêt Pour arrêter le serveur MySQL, tapez la commande suivante dans un terminal: sudo service mysql stop Rechargement de la configuration Pour que MySQL prenne en compte les modifications de sa configuration, commande suivante dans un terminal: sudo service mysql reload Forcer la prise en compte de la nouvelle configuration sudo service mysql force-reload Configuration Lancer la console MySQL mysql> mysql> use votre_base.