![]() |
OK, so officially, the entities in a Relational Database are called just that: Within that context, there will be [or should be] one column of the table which is used to uniquely
identify or differentiate any row from any other row in that table. This column [attribute] is
called a |
|
In order to organize the database components to make things more effective, we go through a process
known as There are several objectives of normalization, as specified by Edgar Codd when he invented the idea of relational databases in the early 1970's: |
![]() |
Notice the word dependencies in the last item. This is one of the main concepts that we need to consider when working to normalize. A dependency is a relationship between two attributes within an entity, such that one of them can determine the other. For example, you might have a table that contains student information, with fields for student ID and student name. This would be a dependency, because each student has a unique student ID, while there may be multiple named Bartholemew Leznorsmorphels. The student name, then, depends on the student ID. However, the reverse is NOT true.
There are several types of dependencies:
{A,B} —> Bis trivial. If you already know the value of B, you don't need the
{A,B}to determine its value.
{SSN, age} —> nameis a functional dependency, because the SSN can determine the name. However, it is not a full functional dependency because you can remove age from the left side and still determine the name from the SSN. On the other hand, the dependency
{Employee_number,Hours} —> weely_pay*is* a full funcitonal dependency, because you need both Employee_number and Hours values to determine how much the employee is paid for the week.
A —> Cis a transitive dependency when it is true only because *both* the dependencies
A —> Band
B —> Care true.
![]() |
Dependencies are important because they are what we need to deal with to normalize the database to make it more efficient. The process is to break the data apart, reorganizing it based on the logical relationships between the entities/attributes, to minimize the duplication of the data within the schema. Why? Because duplicated data can waste storage space, for one thing, but [perhaps more importantly] any duplicate data can lead to inconsistencies in the data. [Think about the reasons we eschew magic numbers in our code.] The idea, though, is to be discriminating about the process – we try to strike a balance between a logical, well-normalized schema, and having queries that will execute quickly and that are easy to understand and maintain. |
|
There are several types or levels of |
1st |
| 2nd |
Next, a database is in second normal form if there is no repeating or redundant data
across any rows in the same table. For example, consider a table that keeps track of people
buying books, that has the columns |
|
Next up, a database is in third normal form if there is no data in any table that is *NOT* dependent
on that table's primary key. If you have normalized to second normal form, there may actually be
no need to do anything to get to third normal form, because every table will already be there. However, it
is a good idea to check, just for insurance. For instance, assume you have started with a table that contains
addresses. If you think of the addresses as NOT related to the user but as being |
3rd |
There are several more normal forms: BCNF comes after third, and fourth comes after that. There is even
a fifth normal form. However in practice, these last three are not used too often, partly because of
the law of diminishing returns
These are a couple of acronyms that you should remember. Remeber them because of the importance of the database concepts they represent, NOT because they are cute acronnyms. They reflect key elements that are part of every database management system [DBMS].
ACID stands for:
all or nothingrule. This is the part of database operations which involves transaction processing to ensure that the data in the database remains consistent with every operation.
durablebecause it will not have changed since the operation failed.
CRUD stands for the four basic operations that can be performed in a database:
Constraints in database parlance are just that: things that must be taken into account when performing any operation on the data, which may limit or even prohibit the operation to take place. In some database engines, constrains also are used [required] to designate the primary key for a table. There are several types of constraints. Here are a few that are noteworthy:
NOT NULLand
UNIQUE[see below]. This can be done in several ways, differing syntaxes for different database engines
Index int NOT NULL UNIQUEor after the declarations as
UNIQUE Index, or even using the
CONSTRAINTkeyword, as
CONSTRAINT constr01 UNIQUE (Index)[where constr01 is the constraint name]
INSERTstatement doesn't specify one
ALTER TABLEcommand, prior to removing the constraint.
Stored Procedures are a way of programming repetitive or frequently-used database operations so that they
can be done by a much simpler query
that if the query was being written and executed by the
underlying application. For example, instead of having the query…
SELECT AMT_AssetTable.AssetID ,AMT_AssetTable.AsBuiltRevision ,AMT_AssetTable.AssetType ,AMT_AssetTable.PreviousRecord ,AMT_AssetTable.SerialNumber ,AMT_AssetTable.LastCalDate ,AMT_AssetTable.CalCycleDurationDays ,AMT_AssetTable.LastPMDate ,AMT_AssetTable.PMCycleDurationDays ,AMT_AssetTable.LocationBldgRm ,AMT_AssetTable.AssetDescription ,AMT_StatusValuesTable.StatusValue ,AMT_HistoryLogTable.HistoryLogID ,AMT_HistoryLogTable.BEMSID ,AMT_HistoryLogTable.EntryDate ,AMT_HistoryLogTable.EntryType ,AMT_HistoryLogTable.Title FROM AMT_AssetTable INNER JOIN AMT_StatusValuesTable ON AMT_AssetTable.StatusIndexID = AMT_StatusValuesTable.StatusIndexID INNER JOIN AMT_HistoryLogTable ON AMT_AssetTable.AssetID = AMT_HistoryLogTable.AssetID WHERE AMT_AssetTable.AssetID LIKE 'G123461';Code from Microsoft SQL Server 2014
…you could have the following query…
EXEC AMT_QueryAssetInfoWithStatusAndHistory 'G123456';
Not only does this make your application code much cleaner and easier to read/maintain, it also improves the security of your database, because you can grant stored procedure permissions to specific users, and keep everyone else from executing them.
Stored procedures are not available in all database engines. Some, like older versions of Microsoft Access, have no such facility. Others provide the ability, but may call it by another name. But no matter what it's called or how it's implemented, it provides you with the ability to write functions, include if/then statements and loops, and much more.
MySQL is an open source database management system. It is highly popular because of its high reliability, ease of use and high performance. MySQL is used for many latest applications that are built on Apache, Linux, Perl/PHP etc. Many popular organizations such as Google, Alcatel Lucent, Facebook, Zappos and Adobe rely on this database management system.
MySQL can run on more than twenty platforms that include MAC OS, Windows, Linux, IBM AIX, HP-UX and provides much flexibility. A wide variety of database tools, services, training and support is provided by MySQL database system. MySQL comes in several different editions:
SQL Server is a RDBMS (Relational Database Management System) developed by Microsoft. This system works on Transact-SQL which is a set of programming extensions from Microsoft and Sybase. T-SQL adds other features that include error and exception handling, transaction control, declared variables and row processing. However, Sybase developed the original SQL Server back in 1980s. The final version was called SQL Server 4.2 that was developed in collaboration with Ashton-Tate, Sybase and Microsoft for OS/2.
SQL Server 2005 was launched in the month of November 2005. This version provided enhanced reliability, flexibility, security and scalability to database applications. The features provided by SQL Server are:
For Businesses, SQL server also provides Integration Services, Reporting Services, Data mining, key performance indicators, clustering support, proactive caching and repot building. It also provides integration with Microsoft Office tools [of course].
PostgreSQL is an ORDBMS or Object Relational Database Management. It was developed at the Berkeley Computer Science Department of University of California. It is also an open source database management system and comes from the original Berkeley code. A large part of SQL standard is supported by PostgreSQL and it offers many features such as transactional integrity, triggers, foreign keys, multiversion concurrency control, complex queries and views. The user can extend the PostgreSQL by adding new index methods, procedural languages, functions, operators, data types and aggregate functions. As it is open source it can be modified, distributed or used by everyone free of cost for academic, commercial or provide use.
The differences between PostGres and MySQL are as follows: