0% found this document useful (0 votes)
251 views26 pages

SQL - ERD Homework

The document discusses key concepts in SQL and entity relationship diagrams (ERDs). It defines terms like cardinality, composite attributes, weak entities, primary keys, foreign keys, and provides examples of a relational schema, ERD, and star schema. It also outlines common SQL statements like SELECT, CREATE TABLE, DELETE, INSERT and clauses like GROUP BY, LIKE, LIMIT, ORDER BY, WHERE.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views26 pages

SQL - ERD Homework

The document discusses key concepts in SQL and entity relationship diagrams (ERDs). It defines terms like cardinality, composite attributes, weak entities, primary keys, foreign keys, and provides examples of a relational schema, ERD, and star schema. It also outlines common SQL statements like SELECT, CREATE TABLE, DELETE, INSERT and clauses like GROUP BY, LIKE, LIMIT, ORDER BY, WHERE.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

SQL – ERD Homework

Entity-Relationship model
What is the meaning of “Cardinality” ?
• On an ER Diagram, Cardinality notations
define the attributes of the relationship
between entities in terms of numbers.
• http://searchcrm.techtarget.com/definition/entity-relationship-diagram
Explain the different type of
cardinalities
• There are three main cardinal relationships:

• One-to-one (1:1). For example, if each customer in a


database is associated with one mailing address.
• One-to-many (1:M). For example, a single customer
might place an order for multiple products. The customer is
associated with multiple entities, but all those entities have
a single connection back to the same customer.
• Many-to-many (M:N). For example, at a company where
all call center agents work with multiple customers, each
agent is associated with multiple customers, and multiple
customers might also be associated with multiple agents.
• http://searchcrm.techtarget.com/definition/entity-relationship-diagram
Examples
https://www.lucidchart.com/pages/ER-diagram-symbols-and-meaning
Define Composite Attribute
• An attribute can be simple or composite. If we
consider the name in two parts, last name and
first name, then the name attribute is a
composite. https://wofford-
ecs.org/DataAndVisualization/ermodel/material.htm

• Composite attributes are further divided in a tree


like structure. Every node is then connected to its
attribute. That is, composite attributes are
represented by ellipses that are connected with
an ellipse.
https://www.tutorialspoint.com/dbms/er_diagram_representation.htm
Composite Attribute Continued
Define Weak Entity
• Weak entities depend on some other entity
type. They don't possess unique attributes
(also known as a primary key) and have no
meaning in the diagram without depending on
another entity. This other entity is known as
the owner.
• https://www.lucidchart.com/pages/ER-diagram-symbols-and-meaning
Define Primary Key
• The primary key is an attribute or a set of attributes that
uniquely identify a specific instance of an entity. Every
entity in the data model must have a primary key whose
values uniquely identify instances of the entity.
• To qualify as a primary key for an entity, an attribute must
have the following properties:
• It must have a non-null value for each instance of the entity
• The value must be unique for each instance of an entity
• The values must not change or become null during the life
of each entity instance.
http://condor.depaul.edu/gandrus/240IT/accesspages/primary-foreign-keys.htm
Define Foreign Key
• Foreign key: term used in relational databases
(but not in the E-R model) for an attribute that is
the primary key of another table and is used to
establish a relationship with that table where it
appears as an attribute also.
• So a foreign key value occurs in the table and
again in the other table. This conflicts with the
idea that a value is stored only once; the idea
that a fact is stored once is not undermined.
http://jcsites.juniata.edu/faculty/rhodes/dbms/ermodel
Define Foreign Key
What is the Relational Schema?
Provide example
• A relational database schema is the tables, columns
and relationships that make up a relational database.
A schema is often depicted visually in modeling
software such as ERwin or drawing software such as
Viso. https://www.techwalla.com/articles/what-is-relational-database-schema
• http://www.service-architecture.com/articles/object-relational-
mapping/relational_schema_for_example.html
What is Entity Relational Diagram?

• An entity-relationship diagram (ERD) is a


graphical representation of an information
system that shows the relationship between
people, objects, places, concepts or events within
that system. An ERD is a data modeling technique
that can help define business processes and can
be used as the foundation for a relational
database. http://searchcrm.techtarget.com/definition/entity-relationship-
diagram
Entity Relational Diagram example
What is Star Schema?
• In data warehousing and business intelligence
(BI), a star schema is the simplest form of a
dimensional model, in which data is organized
into facts and dimensions. A fact is an event that
is counted or measured, such as a sale or login. A
dimension contains reference information about
the fact, such as date, product, or customer. A
star schema is diagramed by surrounding each
fact with its associated dimensions. The resulting
diagram resembles a
star. http://searchdatamanagement.techtarget.com/definition/star-schema
Star Schema example
Tarea #2
• https://www.codecademy.com/articles/sql-commands?r=master
Statement #1: SELECT
• SELECT statements are used to fetch data from
a database. Every query will begin with
SELECT.
Statement #2: SELECT DISTINCT
• SELECT DISTINCT specifies that the statement
is going to be a query that returns unique
values in the specified column(s).
Statement #3: CREATE TABLE
• The CREATE TABLE statement is used to create
a new table in a database.
https://www.w3schools.com/sql/sql_create_table.asp
Statement #4: DELETE
• DELETE statements are used to remove rows
from a table.
Statement #5: INSERT
• INSERT statements are used to add a new row
to a table.
Clause 1: GROUP BY
• It is only used with aggregate functions. It is
used in collaboration with the SELECT
statement to arrange identical data into
groups.
Clause 2: LIKE
• LIKE is a special operator used with the
WHERE clause to search for a specific pattern
in a column.
Clause 3: LIMIT
• LIMIT is a clause that lets you specify the
maximum number of rows the result set will
have.
Clause 4: ORDER BY
• ORDER BY is a clause that indicates you want
to sort the result set by a particular column
either alphabetically or numerically.
Clause 5: WHERE
• WHERE is a clause that indicates you want to
filter the result set to include only rows where
the following condition is true.

You might also like