The basic concepts of a relational database are fairly easy to
understand. A relational database is a collection of
related information that has been organized into structures known as tables. Each table contains rows
that are further organized into columns. These tables are
stored in the database in structures known as schemas,
which are areas where database users may store their tables. Each user may also
choose to grant permissions to other users to access their tables.
MySQL Subqueries?
PMA05:07
You can use the result of a query like you use a list of values
with the IN operator to filter a query based on the result of another
query. The subquery appears in parentheses after the IN keyword.
The following query fetches all columns from the products
table, but only for those product codes that were part of order number 1:
mysql> SELECT * -> FROM products -> WHERE product_code IN ( -> SELECT product_code -> FROM order_lines -> WHERE order_id = 1 -> ); +--------------+---------------+--------+--------+ | product_code | name | weight | price | +--------------+---------------+--------+--------+ | MINI | Small product | 1.50 | 5.99 | | MAXI | Large product | 8.00 | 15.99 | +--------------+---------------+--------+--------+ 2 rows in set (0.00 sec)
MySQL Triggers
PMA05:05
To create a new trigger, use the CREATE TRIGGER
statement. You must give the trigger a unique name and then provide the timing,
action, and table that will cause the trigger to fire. For example, to create a
trigger that will fire every time a row is deleted from the products table, you
would construct a trigger as follows:
CREATE TRIGGER trigger_name BEFORE DELETE ON products FOR EACH ROW BEGIN ... END
The timing for a trigger can be BEFORE or
AFTER, indicating whether the trigger code should be executed
immediately before or immediately after the SQL statement that causes the
trigger to fire.
The keywords FOR EACH ROW are part of the CREATE
TRIGGER syntax and are required in every trigger.
what is Triggers?
PMA05:04
A trigger is a stored database object that contains a series of
SQL commands, set to activate automatically when certain events take place.
Each trigger is associated with a table. You can create a
trigger that will fire when an INSERT, UPDATE, or
DELETE takes place on the named table.
Locating commands?
PMA04:58
$ echo $PATH
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/chris/bin
especially if the command resides in a directory with a long name.
The better way is to have commands stored in well-known directories,
and then add those directories to your shell's PATH environment variable.
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/chris/bin
especially if the command resides in a directory with a long name.
The better way is to have commands stored in well-known directories,
and then add those directories to your shell's PATH environment variable.
Common Linux Features?
PMA04:54
-
Multiuser — Not only can you have many user accounts available on a Linux system, you can also have multiple users logged in and working on the system at the same time. Users can have their own environments arranged the way they want: their own home directory for storing files and their own desktop interface (with icons, menus, and applications arranged to suit them). User accounts can be password-protected, so that users can control who has access to their applications and data.
-
Multitasking — In Linux, it is possible to have many programs running at the same time, which means that not only can you have many programs going at once, but that the Linux operating system can itself have programs running in the background. Many of these system processes make it possible for Linux to work as a server, with these background processes listening to the network for requests to log in to your system, view a Web page, print a document, or copy a file. These background processes are referred to as daemons.
-
Graphical User Interface (X Window System) — The powerful framework for working with graphical applications in Linux is referred to as the X Window System (or simply X). X handles the functions of opening X-based graphical user interface (GUI) applications and displaying them on an X server process (the process that manages your screen, mouse, and keyboard).On top of X, you use an X-based desktop environment to provide a desktop metaphor and window manager to provide the look-and-feel of your GUI (icons, window frames, menus, and colors, or a combination of those items called themes). There are several desktop environments and several desktop managers to choose from. (Red Hat provides a few desktop managers, but focuses on GNOME and KDE desktop environments.)
-
Hardware support — You can configure support for almost every type of hardware that can be connected to a computer. There is support for floppy disk drives, CD-ROMs, removable disks (such as DVDs and Zip drives), sound cards, tape devices, video cards, and most anything else you can think of.
-
Networking connectivity — To connect your Linux system to a network, Linux offers support for a variety of local area network (LAN) boards, modems, and serial devices. In addition to LAN protocols, such as Ethernet (both wired and wireless), all the most popular upper-level networking protocols can be built-in. The most popular of these protocols is TCP/IP (used to connect to the Internet). Other protocols, such as IPX (for Novell networks) and X.25 (a packet-switching network type that is popular in Europe), are also available.
-
Network servers — Providing networking services to the client computers on the LAN or to the entire Internet is what Linux does best. A variety of software packages are available that enable you to use Linux as a print server, file server, FTP server, mail server, Web server, news server, or workgroup (DHCP or NIS) server.
-
Application support — Because of compatibility with POSIX and several different application programming interfaces (APIs), a wide range of freeware and shareware software is available for Linux. Most GNU software from the Free Software Foundation will run in Linux (although some may take a bit of tweaking).
-
What Is an Operating System?
PMA04:53
An operating system is made up of software
instructions that lie between the computer hardware (disks, memory, ports, and
so on) and the application programs (word processors, Web browsers,
spreadsheets, and so on). At the center is the kernel, which
provides the most basic computing functions (managing system memory, sharing the
processor, opening and closing devices, and so on). Besides the kernel, an
operating system provides other basic services needed to operate the computer,
including:
-
File systems — The file system provides the structure in which information is stored on the computer. Information is stored in files, primarily on hard disks inside the computer. Files are organized within a hierarchy of directories. The Linux file system holds the data files that you save, the programs you run, and the configuration files that set up the system.
-
Device drivers — These provide the interfaces to each of the hardware devices connected to your computer. A device driver enables a program to write to a device without needing to know details about how each piece of hardware is implemented. The program opens a device, sends and receives data, and closes a device.
-
User interfaces — An operating system needs to provide a way for users to run programs and access the file system. Linux has both graphical and text-based user interfaces. GNOME and KDE provide graphical user interfaces, whereas shell command interpreters (such as bash) run programs by typing commands and options.
-
System services — An operating system provides system services, many of which can be started automatically when the computer boots. In Linux, system services can include processes that mount file systems, start your network, and run scheduled tasks. In Linux, many services run continuously, enabling users to access printers, Web pages, files, databases, and other computing assets over a network.
What is the difference between internal and external commands?
PMA04:21
Internal commands are commands that are already loaded in the system.
They can be executed any time and are independent
They can be executed any time and are independent