A database is both the software and hardware responsible for storing and managing data. A database file consists of rows and columns of data. A database "object", or entity, has a name, and any number of attributes. The name is a row in the database, and the attributes are the columns for that row. For example, an entity named User might have the attributes 'first name', 'last name', 'username', etc.
figure1a: shows the rows and columns for the database table "Users". When queried the data returned shows two records on file.
mysql> select * from users; +----+------------+------------+-------------+ | id | first_name | last_name | username | +----+------------+------------+-------------+ | 1 | john | kline | johnnyboyd | | 2 | lauren | dixon | laurenipsum | +----+------------+------------+-------------+ 2 rows in set (0.01 sec)
A database can represent multiple entities, can store multiple instances of an entity (an object), and objects can be related to other objects through the use of keys and foreign keys. Once the objects are related, one can form a variety of "database queries", which allow one to retrieve sets of related data from this matrix of objects, to be displayed in any order we like. For instance, display all Users who placed an order for item x over the period y to z.
All databases can have their data manipulated through the use of SQL, or Structured Query Language. There are a variety of database brands to choose from, but they each do the same thing, that is Create, Read, Update, and Delete rows of data. A database can be as simple or as complex as you like, but it is the thing which allows an application to store, retrieve or modify information about a particular object. There is virtually no limit to the sort or amount of data an application can have. Now there is a heavy piece of information.
A programming language is the code that gives a computer its ability to think and act based on certain conditions. With programming languages, one can set variables, define functions, and write conditional logic, or statements which tell the computer, "If a is b, then do c, else do d."
figure2a: shows the flow of logic in determining a customer's price of admission. The cost varies depending on the customer's age.
There are thousands of programming languages to choose from. If you learn one programming language, you learn them all, in part. They are each alike in that they give a computer its ability to think and act based on certain conditions. They differ by the type of problem they were created to solve, and in syntax, or, the way in which the language's code is written.
figure2b: shows figure2a expressed in Ruby code. This program retrieves information from the user, sets variables based on the response, then makes a decision to be reflected in the response.
# get customer age puts "enter your age: " # store age in an integer variable age = gets.to_i # set cost variable based on age if (age < 13) cost = 10 else cost = 20 end # respond with determined cost of admission puts "tickets are $" + cost.to_s
With databases, programming languages, and frameworks, a developer can give a website its own form of intelligence, and with it, the ability to remember and respond uniquely to its visitors. With this ability, a website can grant full access to its administrator, all the while restricting the general public from the same. With memory and discernment, users can manage and update a website's content, create and modify its records, and be recognized when they return. When a person updates their status on social media, for example, they are actually updating that site's content by creating a record in the database. All thanks to the help of databases, programming languages, and frameworks. Excellent!
posted over 2 years ago