Entities and Attributes
Jump to navigation
Jump to search
Entity Defined
Something of significance to the business about which data must be known
A name for a set of similar things that you can list
Usually a noun
Examples: object, events, people
Entities have instances
An instance is a single occurrence of an entity
File:Https://www.dropbox.com/s/lv1njvxls0lryth/entities.jpeg?dl=0
- Conceptual model: A data model, usually represented by an entity relationship diagram (ERD)
- The client dream would be the conceptual model
- Physical model: A design for an object (a car, a house, a database, etc) which includes implementation details such as size, volume, weight, etc)
- The physical reality will become the physical model
- All many-to-many relationships must be reduced to a set of on-t--many relationships
Database Normalization
Storing data in a normalized format means only one update is required to reflect the new address, and it should always be the one that appears whenever your mailing address is needed.
Many people unfamiliar with database design principles often ask, “Why not just put all the data in one big table?” This single-table approach leads to problems of data redundancy (duplication) and data anomalies (data inconsistencies).
To avoid these data issues, database normalization is used to create a design that reduces or eliminates data redundancy and, therefore, avoids data anomalies. In general, normalization helps database designers determine which attributes, or fields, belong to each entity. In turn, this information helps determine which fields belong in each table. Normalization is a multistage process that enables designers to take the raw data to be collected about an entity and develop the data into a structured, normalized form that reduces the risks associated with data redundancy. Data redundancy poses a special problem in databases because storing the same data in different places can cause problems when updates or changes to data are required.
When a record contains repeating groups (that is, multiple entries for a single column), it’s considered unnormalized. First-normal form (1NF) indicates that all values of the columns are atomic—meaning they contain no repeating values. To convert records to 1NF, remove the repeating values by making each author entry a separate record,
When more than one field is used as the primary key for a table, the combination of fields is usually referred to as a composite primary key
Now that the repeating values have been eliminated and the records can be identified uniquely, the data is in 1NF
A problem known as partial dependency can occur when the primary key consists of more than one field. Partial dependency means the fields contained in a record (row) depend on only one portion of the primary key
By removing Partial dependency your table is now second-normal-form (2NF)
A transitive dependency means at least one value in the record isn’t dependent on the primary key but on another field in the record. In this case, the contact person from the publisher’s office is actually dependent on the publisher, not on the book.
Levels of Normalization
1NF: Eliminate all repeating values and identify a primary key or primary composite key.
2NF: Make certain the table is in 1NF and eliminate any partial dependencies.
3NF: Make certain the table is in 2NF and remove any transitive dependencies.
A many-to-many relationship can’t exist in a relational database. The most common approach to eliminating a many-to-many relationship is to create two one-to-many relationships by adding a bridging entity. A bridging entity is placed between the original entities and serves as a “filter” for the data.
SQL Command Types
- Query
- SELECT(Retrieve the data values)
- Data manipulation language (DML)
- INSERT, UPDATE, DELETE (Create or modify data values)
- Data definition language (DDL)
- CREATE, ALTER, DROP (define data structures)
- Transaction control (TC)
- COMMIT, ROLLBACK (Save or undo data value modifications)
- Data control language(DCL)
- GRANT, REVOKE (Set permissions to access database structures)