I am designing a database structure for a mail list
The data i need to record is the mail receiver data:
Since the mail receiver data is not predefine,
it cause a problem:
for example:
some of the receiver have name, mail address, phone no
while the others have name, birthdate, mail address, gender, etc…
So my design is like this:
Table Receiver:
PK: ReceiverID
AttributeID
DataID
Table Attribute:
PK: AttributeID
AttributeName
Table Data:
PK: DataID
DataContent
A example of one receiver is:
Receiver: 1 1 1
Attribute: 1 mailAddress
Data:1 test@test.com
Receiver: 1 2 2
Attribute: 2 Name
Data:2 Tony
This cause a problem because i want to check the data field type and length, what is a better database design? Sorry about the poor description, i would clarify it if you are confused .Thanks a lot.
Its impossible per definition to define datatypes for unknown attributes. This is just how databases work.
I understand you want the birthday to be a DATETIME column. (and possibly other “special” datatypes for a few other attributes)
I cannot believe the impossiblity to predefine the available attributes – they are limited. just go ahead and define a list of possible attributes.
A better database design would be to just create a receiver table that contains all possible fields and allows them to be NULL. Using the database as a “generic storage” for arbitrary attributes is bad practice when not necessery.
your table could look like this:
And your data could look like this: