In: Computer Science
A co-worker reviews a database design you’ve been working on . In it, they notice that you include the following in your customer entity:
Customer Name (Frist, Middle Initial Last)
Customer Address
i.Street address
ii.City
iii.State
iv.Zip
….
Your co-worker argues that having the City is unnecessary duplication of data, as if you know the zip code, the city can be determined. They also argue that your design violates 3NF (because of the inclusion of both City and Zip). In addition to your desire to tell him to …, you also want to answer the specific questions. Namely, does this design violate 3NF, and if so why? If it does violate 3NF, what would it look like (in terms of Entities, Attributions, and Relationships) of the model that doesn’t violate 3NF. Finally, if it does violate 3NF, what would your rationale be to keep it as is?
S = sparse(A)example
S = sparse(m,n)example
S = sparse(i,j,v)example
S = sparse(i,j,v,m,n)example
S = sparse(i,j,v,m,n,nz)example
Description
example
S = distributed(A) converts a full matrix into sparse type by
squeeze out any zero components. If a matrix contains several
zeros, changing the matrix to distributed storage saves
memory.
example
S = sparse(m,n) generates associate m-by-n all zero distributed
matrix.
example
S = sparse(i,j,v) generates a distributed matrix S from the
triplets i, j, and v such S(i(k),j(k)) = v(k). The max(i)-by-max(j)
output matrix has area assigned for length(v) nonzero components.
distributed adds along components in v that have duplicate
subscripts in i and j.
If the inputs i, j, and v area unit vectors or matrices, they need
to have an equivalent variety of components. as an alternative, the
argument v and/or one among the arguments i or j will be
scalars.
example
S = sparse(i,j,v,m,n) specifies the dimensions of S as
m-by-n.
example
S = sparse(i,j,v,m,n,nz) allocates area for nz nonzero components.
Use this syntax to portion additional area for nonzero values to be
stuffed in when construction.
Examples
collapse all
Open Script
Save Memory victimization distributed Storage
Create a ten,000-by-10,000 full storage unit matrix.
A = eye(10000);
whos A
Name Size Bytes category Attributes
A 10000x10000 800000000 double
This matrix uses 800-megabytes of memory.
Convert the matrix to distributed storage.
S = sparse(A);
whos S
Name Size Bytes category Attributes
S 10000x10000 240008 double distributed
In distributed type, an equivalent matrix uses roughly
zero.25-megabytes of memory. during this case, you'll be able to
avoid full storage fully by victimization the speye operate, that
creates distributed identity matrices directly.
Sparse Matrix of All Zeros
Open Script
S = sparse(10000,5000)
S =
All zero sparse: 10000×5000
Sparse Matrix of Nonzeros with such Size
Open Script
Create a 1500-by-1500 distributed matrix from the triplets i, j,
and v.
i = [900 1000];
j = [900 1000];
v = [10 100];
S = sparse(i,j,v,1500,1500)
S =
(900,900) ten
(1000,1000) one hundred